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

Home Page:https://www.donet5.com/Home/Doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception in {"Index was outside the bounds of the array."} When use Join three table

mrreddevil2412 opened this issue · comments

qurery linq
image

Respository Query

image

Exception

image

Queryable<T1,T2,T3,T4>

 //error
new JoinInfos(joinType,exp)

//ok
(a,b,c,d)=>new JoinInfos(joinType,a.id==b.id,JoinType,b.id==c.id,JoinType ,c.id==d.id)

If there are four tables, then a JOIN operation involves three joins

I'm join three table and want to return new ApproViewModel

I'm fixed :)
I forgot, I had to move the select function after the orderby function.
Thank you for supported!

 
db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
    JoinType.Left, o.Id == i.OrderId,  
    JoinType.Left, o.CustomId == c.Id 
))
.Orderby((o,i,c)=>o.Id)
.Select((o,i,c)=>new ViewModel{ name=o.Name ..})
.ToList()
 

OR

 
db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
    JoinType.Left, o.Id == i.OrderId,  
    JoinType.Left, o.CustomId == c.Id 
))

.Select((o,i,c)=>new ViewModel{ name=o.Name ..})
.MergeTable()
.Orderby(it=>it.Name)
.ToList()