Beispiel #1
0
        private static StanceModel Create(DbDataReader reader)
        {
            StanceModel model;

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

            return(model);
        }
        public void Delete()
        {
            QueryInformation query;

            if (this.Id == Guid.Empty)
            {
                Debug.WriteLine("Error: You can't delete this record as one doesn't exist for it. StanceGroupModel:Delete()");
                return;
            }
            //We need to delete any associated records first before deleteing this Stance record
            StanceModel.DeleteAllByStanceGroupId(this.Id);

            query = QueryInformation.Create(StanceGroupModel.DeleteQuery);

            query.CommandType = CommandType.Text;
            query.Parameters.Add(new QueryParameter("@" + StanceGroupModel.IdField, DbType.Guid, this.Id));
            BaseModel.RunCommand(query);
            //reset the id so that the model knows it is a new record if someone tries to call the save() method afterwards.
            this.Id = Guid.Empty;
        }