public void select_all_test() { var srcSql = @"SELECT ID, BLOG_NAME, BLOG_AUTHOR, WRITE_DT FROM Blog "; var sqlExpression = new JSqlExpression(); var sql = sqlExpression.Select <Blog>().Build(); Assert.AreEqual(srcSql, sql); }
public void select_query_test() { var srcSql = @"SELECT BLOG_NAME, BLOG_AUTHOR FROM Blog WHERE ID = 1 AND BLOG_NAME = 'test' AND BLOG_NAME LIKE ('test') AND ID IN (1, 2, 3, 4) "; var sqlExpression = new JSqlExpression(); var sql = sqlExpression.Select <Blog>(m => new { m.BLOG_NAME, m.BLOG_AUTHOR }) .Where(m => m.ID == 1) .And(m => m.BLOG_NAME == "test") .And(m => Sql.Like(m.BLOG_NAME, "test")) .And(m => Sql.In(m.ID, new[] { 1, 2, 3, 4 })) .Build(); Assert.AreEqual(srcSql, sql); }