Linq to Nhibernate strange behaviour -
Linq to Nhibernate strange behaviour -
i have table fill query, have references entities.
i have client:
public class client { public virtual int id { get; set; } public virtual icollection<address> addresses { get; protected set; } public virtual address currentaddress { get; set; } }
address
public class address { public virtual int id { get; set; } public virtual string address1 { get; set; } public virtual string city { get; set; } public virtual string zipcode { get; set; } }
and db diagram:
i want users addresses linq nhibernate:
clientrepository.where(x => x.id == clientid).selectmany(c => c.addresses ).where(x => x.address1.contains("comp")).tolist();
but got query:
select top (20 /* @p0 */) id31_, address2_31_, address3_31_, city31_, zipcode31_ (select address2_.id id31_, address2_.address1 address2_31_, address2_.address2 address3_31_, address2_.city city31_, address2_.zipcode zipcode31_, row_number() over( order address2_.address1) __hibernate_sort_row clients client0_ inner bring together addresstoclient addresshis1_ on client0_.id = addresshis1_.clientid inner bring together addresses address2_ on addresshis1_.addressid = address2_.id address2_.id = 2 /* @p1 */) query query.__hibernate_sort_row > 0 /* @p2 */ order query.__hibernate_sort_row
edited repository:
/// <summary> /// gets repository query. /// </summary> /// <value>the repository query.</value> protected override iqueryable<client> repositoryquery { { homecoming session.query<client>(); } }
where query filters id = address2_.id
not client id.
why search appears address id not client?
try changing 1 of 2 "x" variable names different. there bug in current nhibernate release version cause this.
nhibernate linq-to-nhibernate conform
Comments
Post a Comment