public void DeleteModel(QC_HF_ChangeLogModel model, DbTransaction tran) { QC_HF_ChangeLogTable table = new QC_HF_ChangeLogTable(); DeleteSqlSection sql = DataAccess.DefaultDB.Delete(table); if (tran != null) { sql.SetTransaction(tran); } sql.Where(table.QUALITY_CODE == model.QualityCode) .Execute(); }
public void DeleteModel(QcavailablewidthModel model, DbTransaction tran) { QcavailablewidthTable table = new QcavailablewidthTable(); DeleteSqlSection sql = DataAccess.DefaultDB.Delete(table); if (tran != null) { sql.SetTransaction(tran); } sql.Where(table.QualityCode == model.QualityCode) .Execute(); }
private IEnumerable <IInsqlSection> ParseSections(XElement root) { var sqlSections = root.Elements(XName.Get("sql", "")).Select(element => { var id = element.Attribute(XName.Get("id", "")); if (id == null || string.IsNullOrWhiteSpace(id.Value)) { throw new Exception("insql sql section `id` is empty !"); } var section = new SqlInsqlSection(id.Value); section.Elements.AddRange(this.ParseSqlSectionElements(element)); return(section); }).Cast <IInsqlSection>(); var selectSqlSections = root.Elements(XName.Get("select", "")).Select(element => { var id = element.Attribute(XName.Get("id", "")); if (id == null || string.IsNullOrWhiteSpace(id.Value)) { throw new Exception("insql select insert sql section element `id` is empty !"); } var section = new SelectSqlSection(id.Value); section.Elements.AddRange(this.ParseSqlSectionElements(element)); return(section); }).Cast <IInsqlSection>(); var insertSqlSections = root.Elements(XName.Get("insert", "")).Select(element => { var id = element.Attribute(XName.Get("id", "")); if (id == null || string.IsNullOrWhiteSpace(id.Value)) { throw new Exception("insql insert sql section element `id` is empty !"); } var section = new InsertSqlSection(id.Value); section.Elements.AddRange(this.ParseSqlSectionElements(element)); return(section); }).Cast <IInsqlSection>(); var updateSqlSections = root.Elements(XName.Get("update", "")).Select(element => { var id = element.Attribute(XName.Get("id", "")); if (id == null || string.IsNullOrWhiteSpace(id.Value)) { throw new Exception("insql update sql section element `id` is empty !"); } var section = new UpdateSqlSection(id.Value); section.Elements.AddRange(this.ParseSqlSectionElements(element)); return(section); }).Cast <IInsqlSection>(); var deleteSqlSections = root.Elements(XName.Get("delete", "")).Select(element => { var id = element.Attribute(XName.Get("id", "")); if (id == null || string.IsNullOrWhiteSpace(id.Value)) { throw new Exception("insql delete sql section element `id` is empty !"); } var section = new DeleteSqlSection(id.Value); section.Elements.AddRange(this.ParseSqlSectionElements(element)); return(section); }).Cast <IInsqlSection>(); return(sqlSections .Concat(selectSqlSections) .Concat(insertSqlSections) .Concat(updateSqlSections) .Concat(deleteSqlSections) .ToList()); }
public static int DeleteByWhere(EDatabase db, IQueryTable table, WhereClip where, bool withTran) { DeleteSqlSection delSection = db.Delete(table).Where(where); return(withTran ? delSection.ExecuteWithTran() : delSection.Execute()); }