public int Insert(MyTableItem item) { var param = AdoTemplate.CreateDbParameters(); param.AddWithValue("name", item.Name).DbType = System.Data.DbType.String; param.AddWithValue("age", item.Age).DbType = System.Data.DbType.Int32; return((int)AdoTemplate.ExecuteScalar(System.Data.CommandType.Text, "INSERT INTO MyTable (Name, Age) VALUES (@name, @age);SELECT CAST(scope_identity() AS int)", param)); }
public void TestInsert(MyTableItem item) { MyTableDao.Insert(item); MyTableDao2.Insert(item); if (true) { //throw new Exception("TEST"); } }
static void Main(string[] args) { var myMatchConditions = new int?[][] { new int?[] { 1, 1, 100, null }, new int?[] { 2, 2, 125, null }, new int?[] { 3, 3, null, 175 }, new int?[] { 4, 4, 125, 175 } }; var myData = new MyTableItem[] { new MyTableItem { id = 1, listId = 1, listFieldValue = 150, parentId = 1 }, new MyTableItem { id = 2, listId = 1, listFieldValue = 75, parentId = 1 }, new MyTableItem { id = 3, listId = 2, listFieldValue = 150, parentId = 1 }, new MyTableItem { id = 4, listId = 4, listFieldValue = 150, parentId = 1 }, new MyTableItem { id = 5, listId = 5, listFieldValue = 150, parentId = 1 }, }; var matches = from d in myData where myMatchConditions.Any(cond => ( (cond[0] == d.listId) && (cond[1] == 1 ? d.listFieldValue == cond[2] : (cond[1] == 2 ? d.listFieldValue > cond[2] : (cond[1] == 3 ? d.listFieldValue < cond[3] : (cond[1] == 4 ? d.listFieldValue > cond[2] && d.listFieldValue < cond[3] : false) ) ) ) )) group d by d.parentId into g select g; }