Пример #1
0
 public bool Update(Status Status)
 {
     return(template.Execute(
                @"update Status set status=@status where id=@id",
                new QueryParameter("@id", Status.Id),
                new QueryParameter("@status", Status.Name)) == 1);
 }
Пример #2
0
 public bool Update(RaceType raceType)
 {
     return(template.Execute(
                @"update racetype set type=@typ, numberOfRuns=@num where id=@id",
                new QueryParameter("@id", raceType.Id),
                new QueryParameter("@typ", raceType.Type),
                new QueryParameter("@num", raceType.NumberOfRuns)) == 1);
 }
Пример #3
0
 public int Insert(SplitTime splitTime)
 {
     return(template.Execute(
                @"insert into Splittime(racedataId, runNo, splittimeNo, splittime) values (@racedataId, @runNo, @splittimeNo, @splittime); SELECT last_insert_rowid();",
                new QueryParameter("@racedataId", splitTime.RaceDataId),
                new QueryParameter("@runNo", splitTime.RunNo),
                new QueryParameter("@splittimeNo", splitTime.SplittimeNo),
                new QueryParameter("@splittime", splitTime.Time.ToString("HH:mm:ss.fff"))));
 }
Пример #4
0
 public int Insert(StartListMember startListMember)
 {
     return(template.Execute(
                @"insert into startlist(raceId, skierId, runNo, startpos) values (@raceId, @skierId, @runNo,@startpos); SELECT last_insert_rowid();",
                new QueryParameter("@raceId", startListMember.Race.Id),
                new QueryParameter("@skierId", startListMember.SkierId),
                new QueryParameter("@runNo", startListMember.RunNo),
                new QueryParameter("@startpos", startListMember.StartPos)));
 }
Пример #5
0
 public bool Update(Run Run)
 {
     return(template.Execute(
                @"update Run set raceId=@raceId, runNo=@runNo, running=@running, finished=@finished where raceId=@raceId and runNo=@runNo",
                new QueryParameter("@raceId", Run.RaceId),
                new QueryParameter("@runNo", Run.RunNo),
                new QueryParameter("@running", Run.Running),
                new QueryParameter("@finished", Run.Finished)) == 1);
 }
Пример #6
0
 public bool Update(Skier skier)
 {
     return(template.Execute(
                @"update skier set firstname=@fn, lastname=@ln, dateofbirth=@dob , nation=@nat, sex=@sex where id=@id",
                new QueryParameter("@id", skier.Id),
                new QueryParameter("@fn", skier.FirstName),
                new QueryParameter("@ln", skier.LastName),
                new QueryParameter("@dob", skier.DateOfBirth.ToString("yyyy-M-d")),
                new QueryParameter("@nat", skier.Nation),
                new QueryParameter("@sex", skier.Sex)) == 1);
 }
Пример #7
0
 public bool Update(RaceData raceData)
 {
     return(template.Execute(
                @"update RaceData set id=@id, raceId=@rid, skierId=@skid, disqualified=@dis, running=@running, blocked=@blocked, finished=@finished where id=@id",
                new QueryParameter("@id", raceData.Id),
                new QueryParameter("@rid", raceData.RaceId),
                new QueryParameter("@skid", raceData.SkierId),
                new QueryParameter("@dis", raceData.Disqualified),
                new QueryParameter("@running", raceData.Running),
                new QueryParameter("@blocked", raceData.Blocked),
                new QueryParameter("@finished", raceData.Finished)) >= 0);
 }
Пример #8
0
 public bool Update(Race race)
 {
     return(template.Execute(
                @"update Race set typeId=@type, statusId=@status, name=@nam, location=@loc, date=@dat, splittimes=@spl, sex=@sex, deleted = 0 where id=@id",
                new QueryParameter("@id", race.Id),
                new QueryParameter("@type", race.Type.Id),
                new QueryParameter("@status", race.Status.Id),
                new QueryParameter("@nam", race.Name),
                new QueryParameter("@loc", race.Location),
                new QueryParameter("@dat", race.Date.ToString("s")),
                new QueryParameter("@spl", race.Splittimes),
                new QueryParameter("@sex", race.Sex)) == 1);
 }
 public bool InsertStation(Stations station)
 {
     return(template.Execute(
                "insert into Stations values (@station, @stationTyp, @coordinatesLongitude, @coordinatesLatitude, @postalcode)",
                new[]
     {
         new SqlParameter("@station", station.Station),
         new SqlParameter("@stationTyp", station.StationTyp),
         new SqlParameter("@coordinatesLongitude", station.CoordinatesLongitude),
         new SqlParameter("@coordinatesLatitude", station.CoordinatesLatitude),
         new SqlParameter("@postalcode", station.Postalcode)
     }) == 1);
 }
Пример #10
0
 public bool InsertUser(Users user)
 {
     return(template.Execute(
                "insert into Users values (@username, @firstname, @lastname, @emailadress, @station)",
                new[]
     {
         new SqlParameter("@username", user.Username),
         new SqlParameter("@firstname", user.Firstname),
         new SqlParameter("@lastname", user.Lastname),
         new SqlParameter("@emailadress", user.Emailadress),
         new SqlParameter("@station", user.Station)
     }) == 1);
 }
 public bool InsertMeasurement(Measurements measurement)
 {
     return(template.Execute(
                "insert into Measurements values ( @station, @timestamp, @airtemperature, @airpressure, @rainfall, @humidity, @windSpeed, @windDirection)",
                new[]
     {
         new SqlParameter("@station", measurement.Station),
         new SqlParameter("@timestamp", measurement.Timestamp),
         new SqlParameter("@airtemperature", measurement.Airtemperature),
         new SqlParameter("@airpressure", measurement.Airpressure),
         new SqlParameter("@rainfall", measurement.Rainfall),
         new SqlParameter("@humidity", measurement.Humidity),
         new SqlParameter("@windSpeed", measurement.WindSpeed),
         new SqlParameter("@windDirection", measurement.WindDirection)
     }) == 1);
 }
        public void CommandDelegateUsage()
        {
            string name  = "Jack";
            int    count = adoTemplate.Execute <int>(command =>
            {
                command.CommandText =
                    "select count(*) from TestObjects where Name = @Name";

                DbParameter p   = command.CreateParameter();
                p.ParameterName = "@Name";
                p.Value         = name;
                command.Parameters.Add(p);

                return((int)command.ExecuteScalar());
            });

            Assert.AreEqual(1, count);
        }
Пример #13
0
        public void CommandDelegateUsage()
        {
            string postalCode = "1010";
            int    count      = adoTemplate.Execute <int>(delegate(DbCommand command)
            {
                command.CommandText =
                    "select count(*) from Customers where PostalCode = @PostalCode";

                DbParameter p   = command.CreateParameter();
                p.ParameterName = "@PostalCode";
                p.Value         = postalCode;
                command.Parameters.Add(p);

                return((int)command.ExecuteScalar());
            });

            Assert.AreEqual(3, count);
        }
        /// <summary>
        /// Finds the number of customers with the given postal code.
        /// </summary>
        /// <param name="postalCode">The postal code.</param>
        /// <returns>Number of customers with the given postal code.</returns>
        public virtual int FindCountWithPostalCodeWithDelegate(string postalCode)
        {
            // Using anonymous delegates allows you to easily reference the
            // surrounding parameters for use with the DbCommand processing.

            return(AdoTemplate.Execute <int>(delegate(DbCommand command)
            {
                // Do whatever you like with the DbCommand... downcast to get
                // provider specific funtionality if necesary.

                command.CommandText = cmdText;

                DbParameter p = command.CreateParameter();
                p.ParameterName = "@PostalCode";
                p.Value = postalCode;
                command.Parameters.Add(p);

                return (int)command.ExecuteScalar();
            }));
        }
Пример #15
0
 public DataTable QueryDataTable(string cmdText, int startRecord, int maxRecord)
 {
     return(_AdoTemplate.Execute(
                new DataAdapterExecutor(cmdText, startRecord, maxRecord, IDbProvider)
                ) as DataTable);
 }
        public virtual int FindCountWithPostalCode(string postalCode)
        {
            // Type inference allows you not to explicitly write .Execute<ResultObject>

            return(AdoTemplate.Execute(new PostalCodeCommandCallback <ResultObject>(postalCode)).count);
        }
Пример #17
0
 public int GetCountByDelegate()
 {
     return((int)AdoTemplate.Execute(new CommandDelegate(MyDelegate)));
 }
Пример #18
0
            /// <summary>
            /// Gets called by TransactionTemplate.Execute within a
            /// transaction context.
            /// </summary>
            /// <param name="status">The associated transaction status.</param>
            /// <returns>a result object or <c>null</c></returns>
            public object DoInTransaction(ITransactionStatus status)
            {
                AdoTemplate adoTemplate = new AdoTemplate(dbProvider);

                return(adoTemplate.Execute(new TestCommandCallback()));
            }
 /// <summary>
 /// Finds the number of customers with the given postal code.
 /// </summary>
 /// <param name="postalCode">The postal code.</param>
 /// <returns>Number of customers with the given postal code.</returns>
 public virtual int FindCountWithPostalCode(string postalCode)
 {
     return((int)AdoTemplate.Execute(new PostalCodeCommandCallback(postalCode)));
 }