public void TryGetTable() { var db = new EasyDb(); db.DefaultMappingBehavior = DefaultMappingBehavior.None; var table = db.SetTable <User>("users"); Assert.IsNotNull(db.TryGetTable <User>()); Assert.AreEqual(table, db.TryGetTable <User>()); Assert.IsNull(db.TryGetTable <Role>()); }
public void GetQuery_WithDefaults() { var service = this.GetService(); var db = new EasyDb(); db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable; db.SetConnectionStringSettings(@"Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=testdb;Integrated Security=True", "System.Data.SqlClient"); service.SetDb(db); var model = new User { UserName = "******", RoleId = 10 }; var table = db.TryGetTable <User>(); var columnValues = DbHelper.GetInsertColumnValues <User>(model, table); var columns = new List <string>(columnValues.Keys); var result = service.GetQuery <User>(columns, table); Assert.AreEqual("insert into [User] ([UserName],[RoleId]) output inserted.id values (@username,@roleid)", result); }