public void QueryTests() { var user = new User { DateOfBirth = DateTime.Parse("1994-01-04"), GPA = 3.10, ID = 10, LoginDate = null, Name = "Zawar", PIN = 2291, Rating = 9.01, Salary = 100000, TimeStamp = DateTime.Now }; string BeginTransactionQuery = QueryMaker.BeginTransQuery; string CommitTransactionQuery = QueryMaker.CommitTransQuery; string DeleteQuery = QueryMaker.DeleteQuery(user); string DeleteQuery2 = QueryMaker.DeleteQuery <User>(" where 1 = 1"); var sortAndOrder = new Dictionary <string, string>(); sortAndOrder.Add("ID", "desc"); sortAndOrder.Add("TimeStamp", "asc"); var PagerQuery = QueryMaker.GetPagerQueries <User>(null, sortAndOrder, 0, 10); string InsertQuery = QueryMaker.InsertQuery(user); string SelectQuery = QueryMaker.SelectQuery <User>(); string UpdateQuery = QueryMaker.UpdateQuery(user); return; }
public static void InsertProduct(Product p) { string query = QueryMaker.InsertQuery(p) + ";DECLARE @ID INT = ( SELECT SCOPE_IDENTITY() );"; foreach (var element in p.Packaging) { query += $"INSERT INTO Product_Packaging (ProductID , Packaging) VALUES (@ID, '{element}');"; } foreach (var element in p.SKU_PackSize) { query += $"INSERT INTO Product_SKU (ProductID, SKU, Price) VALUES (@ID, '{element.SKU}', '{element.Price}');"; } DBHelper.ExecuteQuery(query); }