When you use Lightspeed to perform a LEFT JOIN or right JOIN operation on a database, you often report strange exceptions.
Clearly the table is not a problem, the surface of the statement is not a problem, can always error. Look at the SQL in the parser, it is lightspeed to the left right join parsing is problematic.
Note: LS to the LEFT join and right join will finally parse into group Join to handle
Of course, this happens only occasionally, because of the way some tables and relationships are created (LS website requires the project to be sent to them to analyze the problem, too much trouble will not continue, specific reasons do not understand)
Now, there's another way to get around this bug (either with findbysql or stored procedures, but I don't want to use SQL statements because the table structure changes and you can't find the problem the first time)
Query Query2 =Newquery{EntityType=typeof(lq_studentapply), QueryExpression= Entity.attribute<lq_studentapply> ("Lq_schoolid") ==SchoolID, Order= Order.by ("CreatedOn"). Descending ()};//handle LEFT JOIN and right join through OuterjoinQuery2. Join = Join.outer (typeof(lq_studentapply),typeof(Lq_member),"Operator","Id");varRst1 =Dbplatform.find (Query2, Query2. Mappings);varSalist = Rst1. Getcollection<lq_studentapply>();varOlist = Rst1. Getcollection<lq_member>();//Inner JoinQuery2. Join = Join.inner (typeof(lq_studentapply),typeof(Lq_member),"Lq_memberid","Id");varRst2 =Dbplatform.find (Query2, Query2. Mappings);varMemlist = Rst2. Getcollection<lq_member>();//flattening data for three tablesvarquery = Salist.zip (Memlist, (SA, mem) = =New{SA=SA, Mem=mem}). Zip (Olist, (Mix, O)=New{MemberID=mix. Mem.id, SId=mix.sa. Id, Operatorname= O! =NULL? O.realname:""});
The parsed SQL statement is basically
SELECT * fromlq_studentapply SA Left JOINLq_member M onSa. Operator=m.idINNER JOINLq_member MEM onSa. Lq_memberid=MEM. IdWHERESa. Lq_schoolid= 'SchoolID'ORDER bySa. CreatedOnDESC
LightSpeed's left Join bug solution