public void CountTest() { var expectedSQL = $"COUNT({column1}) {alias}"; var actualSQL = SqlFunctions.Count(column1, alias); Assert.IsTrue(TestUtil.sqlStringsAreSameLength(expectedSQL, actualSQL)); Assert.IsTrue(TestUtil.sqlStringsMatch(expectedSQL, actualSQL)); }
protected void Page_Load(object sender, EventArgs e) { System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代 using (DNetContext db = new DNetContext()) { var query = db.GetJoin <Book, Author>((m, n) => m.AuthorID == n.AuthorID && n.IsValid == true, (m, n) => m.Price > 10 && n.IsValid == true, (m, n) => new { BookName = m.BookName + n.AuthorName, n.AuthorName }); var books = db.JoinQuery.LeftJoin <Book, Author>((m, n) => m.AuthorID == n.AuthorID && n.IsValid == true) .Fields <Book, Author>((m, n) => new { BookName = m.BookName + "123", AuthorName = SqlFunctions.Count(n.AuthorName) }) .OrderByAsc <Book>(m => m.BookName) .GroupBy <Book, Author>((m, n) => new { m.BookName, n.AuthorName }) .Where <Book, Author>((m, n) => m.Price > 10 && n.IsValid == true && SubQuery.GetList <Author>(n1 => n1.AuthorID >= 1, n1 => n1.AuthorID).Contains(m.AuthorID)) .GetList <Book>(); var join = db.JoinQueryAlias.LeftJoin <Book, Author>((m, n) => m.AuthorID == n.AuthorID && n.IsValid == true) .InnerJoin <Book, Author>((m1, n) => m1.AuthorID == n.AuthorID && n.IsValid == true) .Fields <Book, Author>((m1, n) => new { AuthorName1 = m1.BookName + n.AuthorName, n }) .OrderByAsc <Book>(m => m.BookName); PageFilter page = new PageFilter { PageIndex = 1, PageSize = 10 }; //分页参数前台传来 var pagesource = join.GetPage <Book>(page); } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double milliseconds = timespan.TotalMilliseconds; // 总毫秒数 Response.Write("执行时间:" + milliseconds + "毫秒"); }