My database schema is described below:
Form <-> Log
I have a major entity (Form), one to one relationship to another object (Log) And one to many relationship to the childs (Sellers).
I want to pull out all the Forms that one of their Sellers meets certain conditions.
Unfortunately I'm having some problems:
If I run the following routine:
public void Can_Get_Forms_Where_CorporationNumber_Is_510778087_Metohd0()
var CorporationNumber = "513514950";
var list0 = formRepository
.Where(x => x.Sellers.Any(y => y.CorporationNumber == CorporationNumber))
.Fetch(x => x.Log)
Then I will get sql syntax error
Incorrect syntax near ','
Using NHProf I took the query and found the problem. I reduced my query to Count query to focus on the problem:
10 /* @p0 */)
from BillOfSaleForm form0_
where exists (
from BillOfSaleSeller sellers1_
where form0_.FormID=sellers1_.FormID and
sellers1_.MisparTagid is null)
'513514950' /* @p1 */ is null)
sellers1_.MisparTagid='513514950' /* @p1 */)
We notice that section
*Has Extra brackets*!.
Of course, if we remove the brackets query executed.
I'am using MsSql2005 dialect