public async ValueTask <List <long> > GetMangasWithAllTags(List <long> tagIds) { return(await Context.Queryable <MangaTagMapping>() .Where(it => tagIds.Contains(it.TagId)) .GroupBy(it => it.MangaId) .Having(it => SqlFunc.AggregateDistinctCount(it.TagId) == tagIds.Count) .Select(it => it.MangaId) .Distinct() .ToListAsync()); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().ToList(); var getAll2 = db.Queryable <Order>().Where(it => it.CreateTime.Day >= DateTime.Now.Date.Day).ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var dp = DateTime.Now; var test05 = db.Queryable <Order>().Where(it => it.CreateTime.Month == dp.Month).ToList(); var fromatList = db.Queryable <Order>().Select(it => it.CreateTime.ToString("%Y-%m")).ToList(); var test06 = db.Queryable <Order>().Where(it => it.CreateTime.Date.Day >= DateTime.Now.Date.Day).ToList(); var test07 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Day, Convert.ToDateTime("2021-1-1"), Convert.ToDateTime("2021-1-12"))).ToList(); var q1 = db.Queryable <Order>().Take(1); var q2 = db.Queryable <Order>().Take(2); var test02 = db.Union(q1, q2).ToList(); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var test1 = db.UnionAll( db.Queryable <Order>().Select(it => new ViewOrder() { CustomName = SqlFunc.MergeString(it.Name, "/", it.Name) }), db.Queryable <Order>().Select(it => new ViewOrder() { CustomName = SqlFunc.MergeString(it.Name, "/", it.Name) }) ).ToList(); var test2 = db.Queryable <Order>().Select <ViewOrder>().ToList(); var test3 = db.Queryable <Order>().Select(it => new Order() { CreateTime = SqlFunc.GetDate() }).ToList(); var btime = Convert.ToDateTime("2021-2-1"); var etime = Convert.ToDateTime("2022-1-12"); var test01 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Year, btime, etime)).ToList(); var test02 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Day, btime, etime)).ToList(); var test03 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Month, btime, etime)).ToList(); var test04 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Second, DateTime.Now, DateTime.Now.AddMinutes(2))).ToList(); var test05 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Minute, DateTime.Now, DateTime.Now.AddMinutes(21))).ToList(); var test06 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Hour, DateTime.Now, DateTime.Now.AddHours(3))).ToList(); var test07 = db.Queryable <Order>().Select(it => it.CreateTime.DayOfWeek.ToString()).ToList(); var test08 = db.Queryable <Order>().Select(it => it.CreateTime.AddDays(1)).ToList(); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().Where(it => SqlFunc.EqualsNull(it.Name, null)).ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var btime = Convert.ToDateTime("2021-1-1"); var etime = Convert.ToDateTime("2022-1-12"); var test01 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Year, btime, etime)).ToList(); var test02 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Day, btime, etime)).ToList(); var test03 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Month, btime, etime)).ToList(); var test04 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Second, DateTime.Now, DateTime.Now.AddMinutes(2))).ToList(); var q1 = db.Queryable <Order>().Take(1); var q2 = db.Queryable <Order>().Take(2); var test05 = db.UnionAll(q1, q2).ToList(); Console.WriteLine("#### Examples End ####"); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().Where(it => SqlFunc.EqualsNull(it.Name, null)).ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var getDicionary = db.Queryable <Order>().ToDictionary(it => it.Id, it => it.Name); var getDicionaryList = db.Queryable <Order>().ToDictionaryList(); var getTest = db.Queryable <Order>().Where(it => string.IsNullOrWhiteSpace(it.Name)).ToList(); var test01 = db.Queryable <Order>().PartitionBy(it => it.Id).ToList(); var q1 = db.Queryable <Order>().Take(1); var q2 = db.Queryable <Order>().Take(2); var test02 = db.Union(q1, q2).ToList(); var test03 = db.Queryable <Order>().Take(1).ToList(); var dp = DateTime.Now; var test05 = db.Queryable <Order>().Where(it => it.CreateTime.Month == dp.Month).ToList(); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().Where(it => SqlFunc.EqualsNull(it.Name, null)).ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var getDicionary = db.Queryable <Order>().ToDictionary(it => it.Id, it => it.Name); var getDicionaryList = db.Queryable <Order>().ToDictionaryList(); var getTest = db.Queryable <Order>().Where(it => string.IsNullOrWhiteSpace(it.Name)).ToList(); var test01 = db.Queryable <Order>().PartitionBy(it => it.Id).ToList(); var q1 = db.Queryable <Order>().Take(1); var q2 = db.Queryable <Order>().Take(2); var test02 = db.Union(q1, q2).ToList(); var test03 = db.Queryable <Order>().Take(1).ToList(); var dp = DateTime.Now; var test05 = db.Queryable <Order>().Where(it => it.CreateTime.Month == dp.Month).ToList(); var test06 = db.Queryable <Order>() .ToPivotTable(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test07 = db.Queryable <Order>() .ToPivotList(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test08 = db.Queryable <Order>() .ToPivotJson(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test09 = db.Queryable <Order>().PartitionBy(it => it.Id).ToPageListAsync(1, 2, 0); test09.Wait(); int c = 0; var test10 = db.Queryable <Order>().ToPageList(1, 2, ref c); var test11 = db.Queryable <Order>().GroupBy(it => new { it.CreateTime.Year }).Select(it => it.CreateTime.Year).ToList(); var test12 = db.Queryable <Order>().GroupBy(it => it.CreateTime.Date).Select(it => it.CreateTime.Date).ToList(); var test13 = db.Queryable <Order>().GroupBy(it => new { it.CreateTime.Date, it.CreateTime.Year, it.CreateTime.Minute }) .Select(it => new { it.CreateTime.Date, it.CreateTime.Year, it.CreateTime.Minute }).ToList(); var test14 = db.Queryable <Order>() .GroupBy(it => it.CreateTime.Year) .GroupBy(it => it.CreateTime.Second) .GroupBy(it => it.CreateTime.Date) .Select(it => new { it.CreateTime.Year, it.CreateTime.Second, it.CreateTime.Date }).ToList(); var test15 = db.Queryable <Order, Order>((o, i) => new JoinQueryInfos( JoinType.Left, o.Name == SqlFunc.ToString(SqlFunc.MergeString(",", i.Name, ",")) )) .Select <ViewOrder>().ToList(); var test16 = db.Queryable <Order>().Select(it => SqlFunc.SqlServer_DateDiff("day", DateTime.Now.AddDays(-1), DateTime.Now)).ToList(); var test17 = db.Queryable <Order>() .Select <Order>() .MergeTable() .Select(it => new ViewOrder() { Name = SqlFunc.Subqueryable <Order>().Select(s => s.Name) }).ToList();; var test18 = db.UnionAll( db.Queryable <Order>(), db.Queryable <Order>() ) .Select(it => new ViewOrder() { Name = SqlFunc.Subqueryable <Order>().Select(s => s.Name) }).ToList(); var test19 = db.Queryable <Order>().Select <ViewOrder>().ToList(); var test20 = db.Queryable <Order>().LeftJoin <Custom>((o, cs) => o.Id == cs.Id) .ToDictionary(it => it.Id, it => it.Name); Console.WriteLine("#### Examples End ####"); }
private static void EasyExamples() { Console.WriteLine(""); Console.WriteLine("#### Examples Start ####"); var db = GetInstance(); var dbTime = db.GetDate(); var getAll = db.Queryable <Order>().Where(it => SqlFunc.EqualsNull(it.Name, null)).ToList(); var getOrderBy = db.Queryable <Order>().OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable <Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy3 = db.Queryable <Order>().OrderBy(it => new { it.Name, it.Id }).ToList(); var getRandom = db.Queryable <Order>().OrderBy(it => SqlFunc.GetRandom()).First(); var getByPrimaryKey = db.Queryable <Order>().InSingle(2); var getSingleOrDefault = db.Queryable <Order>().Where(it => it.Id == 1).Single(); var getFirstOrDefault = db.Queryable <Order>().First(); var getByWhere = db.Queryable <Order>().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable <Order>().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable <Order>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); var getByFuns2 = db.Queryable <Order>().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); var getDicionary = db.Queryable <Order>().ToDictionary(it => it.Id, it => it.Name); var getDicionaryList = db.Queryable <Order>().ToDictionaryList(); var getTest = db.Queryable <Order>().Where(it => string.IsNullOrWhiteSpace(it.Name)).ToList(); var test01 = db.Queryable <Order>().PartitionBy(it => it.Id).ToList(); var q1 = db.Queryable <Order>().Take(1); var q2 = db.Queryable <Order>().Take(2); var test02 = db.Union(q1, q2).ToList(); var test03 = db.Queryable <Order>().Take(1).ToList(); var dp = DateTime.Now; var test05 = db.Queryable <Order>().Where(it => it.CreateTime.Month == dp.Month).ToList(); var test06 = db.Queryable <Order>() .ToPivotTable(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test07 = db.Queryable <Order>() .ToPivotList(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test08 = db.Queryable <Order>() .ToPivotJson(it => it.Id, it => it.Name, it => it.Sum(x => x.Price)); var test09 = db.Queryable <Order>().PartitionBy(it => it.Id).ToPageListAsync(1, 2, 0); test09.Wait(); int c = 0; var test10 = db.Queryable <Order>().ToPageList(1, 2, ref c); var test11 = db.Queryable <Order>().GroupBy(it => new { it.CreateTime.Year }).Select(it => it.CreateTime.Year).ToList(); var test12 = db.Queryable <Order>().GroupBy(it => it.CreateTime.Date).Select(it => it.CreateTime.Date).ToList(); var test13 = db.Queryable <Order>().GroupBy(it => new { it.CreateTime.Date, it.CreateTime.Year, it.CreateTime.Minute }) .Select(it => new { it.CreateTime.Date, it.CreateTime.Year, it.CreateTime.Minute }).ToList(); var test14 = db.Queryable <Order>() .GroupBy(it => it.CreateTime.Year) .GroupBy(it => it.CreateTime.Second) .GroupBy(it => it.CreateTime.Date) .Select(it => new { it.CreateTime.Year, it.CreateTime.Second, it.CreateTime.Date }).ToList(); var test15 = db.Queryable <Order, Order>((o, i) => new JoinQueryInfos( JoinType.Left, o.Name == SqlFunc.ToString(SqlFunc.MergeString(",", i.Name, ",")) )) .Select <ViewOrder>().ToList(); var test16 = db.Queryable <Order>().Select(it => SqlFunc.SqlServer_DateDiff("day", DateTime.Now.AddDays(-1), DateTime.Now)).ToList(); var test17 = db.Queryable <Order>() .Select <Order>() .MergeTable() .Select(it => new ViewOrder() { Name = SqlFunc.Subqueryable <Order>().Select(s => s.Name) }).ToList();; var test18 = db.UnionAll( db.Queryable <Order>(), db.Queryable <Order>() ) .Select(it => new ViewOrder() { Name = SqlFunc.Subqueryable <Order>().Select(s => s.Name) }).ToList(); var test19 = db.Queryable <Order>().Select <ViewOrder>().ToList(); var test20 = db.Queryable <Order>().LeftJoin <Custom>((o, cs) => o.Id == cs.Id) .ToDictionary(it => it.Id, it => it.Name); var test21 = db.Queryable <Order>().Where(it => it.Id.ToString() == 1.ToString()).Select(it => it.CreateTime.ToString("24")).First(); var test22 = db.Queryable <Order>().Where(it => it.Id.ToString() == 1.ToString()).Select(it => SqlFunc.AggregateDistinctCount(it.CreateTime)).First(); var test23 = db.Queryable <Order>().Where(it => true).Select(it => new { x1 = it.CreateTime.ToString("yyyy-MM"), it.CreateTime }).ToList(); var test24 = db.Queryable <Order>().Where(it => true).Select(it => new { x1 = it.CreateTime.ToString("yyyy-MM-dd _ HH _ mm _ ss "), it.CreateTime }).ToList(); var test25 = db.Queryable <Order>().Where(it => true).Select(it => new { x1 = it.CreateTime.Month, x2 = DateTime.Now.Month }).ToList(); var test26 = db.Queryable <Order>().Where(it => true).Select(it => new { x1 = it.CreateTime.Day, x2 = DateTime.Now.Day }).ToList(); var test27 = db.Queryable <Order>().Where(it => true).Select(it => new { x1 = it.CreateTime.Year, x2 = DateTime.Now.Year }).ToList(); var test28 = db.Queryable <Order>().Select(it => SqlFunc.DateDiff(DateType.Day, Convert.ToDateTime("2021-1-1"), Convert.ToDateTime("2021-1-12"))).ToList(); var test29 = db.Queryable <Order>().Select(it => new { x = SqlFunc.LessThan(1, 2) }).ToList(); var test30 = db.Queryable <Order>().Select(it => new { x = SqlFunc.LessThanOrEqual(1, 2) }).ToList(); var test31 = db.Queryable <Order>().Select(it => new { x = SqlFunc.GreaterThan(1, 2) }).ToList(); var test32 = db.Queryable <Order>().Select(it => new { x = SqlFunc.GreaterThanOrEqual(1, 2) }).ToList(); List <Order> result = new List <Order>(); db.Queryable <Order>().ForEach(it => { result.Add(it); }, 10); result = new List <Order>(); int count = 0; db.Queryable <Order>().ForEachByPage(it => { result.Add(it); }, 2, 10, ref count, 5); var test33 = db.Queryable <Order>().ToList(); db.CurrentConnectionConfig.SqlMiddle = new SqlMiddle { IsSqlMiddle = true, ExecuteCommand = (s, p) => { return(s.Length); } }; var five = db.Ado.ExecuteCommand("11111"); db.CurrentConnectionConfig.SqlMiddle = null; Console.WriteLine("#### Examples End ####"); }