DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.19k stars 1.32k forks source link

Is there any way to optimize this command? #1205

Closed mrreddevil2412 closed 8 months ago

mrreddevil2412 commented 8 months ago

` var whereEx = Expressionable.Create() .And((f) => !f.IsDeleted) .And((f) => f.Point < 3 || f.Status != 4) .AndIF(offices?.Count > 0, (f) => offices.Select(x => x.Id).Contains(f.UnitID)) .AndIF(model.StartDate > DateTime.MinValue, (f) => f.CreateTime > model.StartDate) .AndIF(model.EndDate > DateTime.MinValue, (f) => f.CreateTime < model.EndDate) .AndIF(model.TypeCustomer.IsNotEmptyOrNull(), (f) => model.TypeCustomer.ToInts().Contains(f.TypeCustomer)) .AndIF(model.TypeFeed.IsNotEmptyOrNull(), (f) => model.TypeFeed.ToInts().Contains(f.TypeFeedback)) .ToExpression(); var queryData = await GetFeedbackEntities(whereEx, offices, model);

foreach (var feedbackEntity in queryData) { feedbackEntity.ProcessHitory = await GetLogFeedbackEntities(feedbackEntity.Id); feedbackEntity.VoucherSend = await GetModSendVoucherEntity(feedbackEntity.Id); feedbackEntity.LogApprove = await GetApproveFeedbackEntities(feedbackEntity.Id); feedbackEntity.Revenue_KHL = await GetRevenueKHL(feedbackEntity.SID); feedbackEntity.Revenue_CTV = await GetRevenueCTV(feedbackEntity.IdPartner); }`

EntityClass

image

Currently, every time I do a for, I have to query to get the dependent object of obj feedbackEntity So do you have a better way to help me?

DotNetNext commented 8 months ago

var list=db.Quyerable().Where(exp) .Include(x=>x.ProcessHitory ) .Include(x=>x.VoucherSend ) .Include(x=>x.LogApprove ) .ToList();

mrreddevil2412 commented 8 months ago

var list=db.Quyerable().Where(exp) .Include(x=>x.ProcessHitory ) .Include(x=>x.VoucherSend ) .Include(x=>x.LogApprove ) .ToList();

Thanks brO!

mrreddevil2412 commented 8 months ago

Can Includes be used with split tables?

image

Class Survey

image
DotNetNext commented 8 months ago

SqlSugarCore 5.1.4.116-preview11 has a major update with split table support for includes

DotNetNext commented 8 months ago

SqlSugarCore 5.1.4.116-preview11 has a major update with split table support for includes

DotNetNext commented 8 months ago

Update, already supported, there are questions to send new isssues

mrreddevil2412 commented 8 months ago

Update, already supported, there are questions to send new isssues Thanks!

SqlSugarCore 5.1.4.116-preview11 has a major update with split table support for includes

it so cool. . I have a function to import excel. There are 2 columns Phone and CustomerCode I need to check before inserting into the table to make sure that record is unique Can you suggest me which function to use in sqlsugar

mrreddevil2412 commented 8 months ago

@DotNetNext SplitTable not support Join query???

image
DotNetNext commented 8 months ago

LeftJoin(db.Queryable().Splitable() ,(x,y)=>x.id==y.xid)

mrreddevil2412 commented 8 months ago

LeftJoin(db.Queryable().Splitable() ,(x,y)=>x.id==y.xid)

Thanks, a tried

image