SqlSugar源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.2 KiB

using OrmTest.UnitTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom09
{
public static void Init()
{
var db = NewUnitTest.Db;
var list=db.Queryable<Order>()
.GroupBy(x => new { CreateTime = x.CreateTime.ToString("yyyy-MM"),x.Name })
.Select(x => new { CreateTime = x.CreateTime.ToString("yyyy-MM") }).ToList();
3 years ago
db.CodeFirst.InitTables<Unitadfaint21>();
db.Insertable(new Unitadfaint21() { id = 1 , id2=22 }).ExecuteCommand();
var list2 = db.Queryable<Unitadfaint21>().ToList();
var list3=db.Queryable<Order>()
// .Where(it=>SqlFunc.ToString(it.Id>0?1:0)=="")
.Select(it => new
{
count = SqlFunc.AggregateSum(it.Id < 20 ? 1 : 0)
//count = SqlFunc.AggregateSum(SqlFunc.IIF(b.客户确认状态 < 20, 1, 0))
3 years ago
}).ToList();
db.Queryable<Tree>().LeftJoin<Tree>((t,y)=>t.Id==y.Id).Where(t=>1==1).Select(t=>t).ToParentList(it => it.ParentId, "0");
db.Queryable<Order>() .Select((a) => new
{
ID = a.Id,
= !string.IsNullOrEmpty(a.Name) ? a.Name : a.Name
}).ToList();
3 years ago
db.Queryable<Order>().Select(x => new
{
// c=SqlFunc.Subqueryable<Order>().Where(z=>z.Id==x.Id).Count(),
x1 = !string.IsNullOrEmpty(x.Name)
}).ToList();
3 years ago
}
public class Unitadfaint21
{
[SugarColumn(ColumnDataType ="int")]
public long? id { get; set; }
[SugarColumn(ColumnDataType = "int")]
public long id2 { get; set; }
}
public class Unitasfa1sadfa
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; }
[SugarColumn(IsNullable = true)]
public bool ItemId { get; set; }
}
}
}