private static RaceLevelDetailModel Create(DbDataReader reader)
        {
            RaceLevelDetailModel model;

            model = new RaceLevelDetailModel();
            model.Load(reader);

            return(model);
        }
예제 #2
0
        public void Delete()
        {
            QueryInformation query;

            if (this.Id == Guid.Empty)
            {
                Debug.WriteLine("Error: You can not delete this record, there is no database entry for it. RaceModel: Delete()");
                return;
            }

            //Need to delete associated records first before deleting the Main record.
            RaceLevelDetailModel.DeleteAllByRaceId(this.Id);
            RaceBonusFeatModel.DeleteAllByRaceId(this.Id);

            query = QueryInformation.Create(RaceModel.DeleteQuery);

            query.CommandType = CommandType.Text;
            query.Parameters.Add(new QueryParameter("@" + RaceModel.IdField, DbType.Guid, this.Id));
            BaseModel.RunCommand(query);

            //lets reset the Id to empty so the model knows it is a new record now if the "Save()" is called afterwards for some reason.
            this.Id = Guid.Empty;
        }