LightSpeed's left Join bug solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.