From: NHibernate J. <mik...@us...> - 2007-03-05 10:02:35
|
Expression.In does not support Generic lists -------------------------------------------- Key: NH-933 URL: http://jira.nhibernate.org/browse/NH-933 Project: NHibernate Type: Bug Components: Core =20 Versions: 1.2.0.CR1 =20 Reporter: Taavi K=C3=B5osaar Priority: Trivial Expression.In takes only ICollection, but since generic lists come from ICo= llection<T>, not from ICollection, it is not possible to put in generic lis= ts.=20 Perhaps a quick solution is to use IEnumerable as input type (IList<T> impl= ements this inetrface, and so do most of the collection/array/List types)? I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 10:14:38
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dall ] Sergey Koshcheyev updated NH-933: --------------------------------- Fix Version: 1.2.0.GA > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 10:36:36
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1520= 3 ] =20 Taavi K=C3=B5osaar commented on NH-933: ---------------------------------- Furthermore i seem to get an exception "Cannot use collections with InExpre= ssion"), when trying to give an array of items into the Expression.In(). Looking at the code, i see this: if (criteriaQuery.GetTypeUsingProjection(criteria, this._propertyName).IsCo= llectionType) { throw new QueryException("Cannot use collections with InExpression"); } The method seem to allow the collection type, but at the same it throws exc= eption when you try to send in an collection (array). Id say this is more serious bug. > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 10:42:33
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1520= 4 ] =20 Sergey Koshcheyev commented on NH-933: -------------------------------------- I'd need to see the code and mappings to know if it's a serious bug or just= a misuse of NHibernate. > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 11:49:37
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1520= 6 ] =20 Taavi K=C3=B5osaar commented on NH-933: ---------------------------------- This is my code: Constants.ClientClientGroups =3D "ClientGroups"; Constants.ClientName =3D "Name"; public IList<Client> SearchMatchingClients(string name, params ClientGroup[= ] clientGroups) { =09DetachedCriteria criteria =3D DetachedCriteria.For<Client>(); =09criteria.Add(Expression.Like(Constants.ClientName, name, MatchMode.Start= )); =09criteria.Add(Expression.In(Constants.ClientClientGroups, clientGroups)); =09 =09return Repository<Client>.FindByDetachedCriteria(criteria); } public static IList<T> FindByDetachedCriteria(DetachedCriteria criteria) { =09ICriteria tempCriteria =3D criteria.GetExecutableCriteria(NHibernateUtil= .GetCurrentSession()); =09IList<T> result =3D tempCriteria.List<T>(); =09return result; } This is my mapping situated with current classes: BusinessInfo (base for Client): <?xml version=3D"1.0" encoding=3D"utf-8"?> <hibernate-mapping default-cascade=3D"save-update" xmlns:xsi=3D"http://www.= w3.org/2001/XMLSchema-instance" xmlns:xsd=3D"http://www.w3.org/2001/XMLSche= ma" xmlns=3D"urn:nhibernate-mapping-2.2"> =09<class =09=09name=3D"Vita.Pesa.Domain.BusinessInfo, Vita.Pesa" =09=09lazy=3D"true" =09=09table=3D"BusinessInfo"> =09=09<id =09=09=09name=3D"Id" =09=09=09column=3D"Id" =09=09=09type=3D"Int32" =09=09=09unsaved-value=3D"0"> =09=09=09<generator =09=09=09=09class=3D"identity" /> =09=09</id> =09=09 =09=09<property =09=09=09name=3D"Name" =09=09=09type=3D"String" =09=09=09column=3D"Name" =09=09=09length=3D"200" =09=09=09not-null=3D"true" /> =09=09</class> </hibernate-mapping> Client: <?xml version=3D"1.0" encoding=3D"utf-8"?> <hibernate-mapping default-cascade=3D"save-update" xmlns:xsi=3D"http://www.= w3.org/2001/XMLSchema-instance" xmlns:xsd=3D"http://www.w3.org/2001/XMLSche= ma" xmlns=3D"urn:nhibernate-mapping-2.2"> =09<joined-subclass =09=09name=3D"Vita.Pesa.Domain.Client, Vita.Pesa" =09=09lazy=3D"true" =09=09extends=3D"Vita.Pesa.Domain.BusinessInfo, Vita.Pesa" =09=09table=3D"Client"> =09=09<key =09=09=09column=3D"BusinessInfoId" /> =09=09<bag =09=09=09name=3D"ClientGroups" =09=09=09inverse=3D"true"> =09=09=09<key =09=09=09=09column=3D"BusinessInfoId" /> =09=09=09<one-to-many =09=09=09=09class=3D"Vita.Pesa.Domain.ClientGroup, Vita.Pesa" /> =09=09</bag> =09</joined-subclass> </hibernate-mapping> ClientGroup: <?xml version=3D"1.0" encoding=3D"utf-8" ?> <hibernate-mapping xmlns=3D"urn:nhibernate-mapping-2.2" default-cascade=3D"= save-update"> =09<class name=3D"Vita.Pesa.Domain.ClientGroup,Vita.Pesa" table=3D"ClientGr= oup" lazy=3D"true"> =09=09<id name=3D"Id" column=3D"Id" type=3D"Int32" unsaved-value=3D"0"> =09=09=09<generator class=3D"identity"/> =09=09</id> =09=09<many-to-one name=3D"Client" column=3D"ClientId" class=3D"Vita.Pesa.D= omain.Client, Vita.Pesa" /> =09=09<many-to-one name=3D"Group" column=3D"ClientGroupClvId" class=3D"Vita= .Pesa.Domain.ClassificatorValue, Vita.Pesa" not-null=3D"true" lazy=3D"false= " /> =09=09<property column=3D"StartDate" type=3D"DateTime" name=3D"StartDate" n= ot-null=3D"true" /> =09=09<property column=3D"EndDate" type=3D"DateTime" name=3D"EndDate" /> =09=09<many-to-one name=3D"State" column=3D"StateClvId" class=3D"Vita.Pesa.= Domain.ClassificatorValue, Vita.Pesa" lazy=3D"false" /> =09</class> </hibernate-mapping> Is this enough? I have limited the mapping files a bit, but what is importa= nt is here. > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 11:51:32
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1520= 7 ] =20 Ayende Rahien commented on NH-933: ---------------------------------- I would say that he is trying to do an In on a collection: Expression.In("Blogs", new Blog[]{..}); > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 11:58:32
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1520= 9 ] =20 Taavi K=C3=B5osaar commented on NH-933: ---------------------------------- Exactly, although the code has class for InExpression, but when using it it= s Expression.In() :) I also tryed using Expression.In("Blogs", new List<Blog>()). (of course wit= h some elements) > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 12:02:33
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1521= 0 ] =20 Sergey Koshcheyev commented on NH-933: -------------------------------------- Use a subcriteria and Expression.In("Blog.Id", listOfIds). This is not a bu= g. > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-05 15:39:37
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dcomments#action_1521= 3 ] =20 Taavi K=C3=B5osaar commented on NH-933: ---------------------------------- You are correct, this seems to work. Although i am getting two instances of the client back in my test, and only= one is added. public IList<Client> SearchMatchingClients(string name, params int[] client= GroupIds) { DetachedCriteria criteria =3D DetachedCriteria.For<Client>(); criteria.CreateCriteria(Constants.ClientClientGroups) .Add( Expression.In(Constants.ClientGroupId, clientGroupIds) ); criteria.Add(Expression.Like(Constants.ClientName, name, MatchMode.Start)= ); return Repository<Client>.FindByDetachedCriteria(criteria, baseCloseSessi= on); } The SQL generated looks like this: SELECT=20 this_.BusinessInfoId as Id7_1_, this_.ClientCardCode as ClientCa2_9_1_, thi= s_.PaymentDeadline as PaymentD3_9_1_, this_.CreditLimit as CreditLi4_9_1_, this_.StateClvId as StateClvId9_1_, th= is_.LastChange as LastChange9_1_, this_.ChangedBy as ChangedBy9_1_,=20 this_.EmployeeId as EmployeeId9_1_, this_.AdditionalInformation as Addition= 9_9_1_, this_.StartDate as StartDate9_1_, this_.EndDate as EndDate9_1_,=20 this_.ElevatedAttention as Elevate12_9_1_, this_.EconomicAffairsConcluded a= s Economi13_9_1_, this_1_.Name as Name7_1_, this_1_.RegistrationCode as Reg= istra3_7_1_, this_1_.VATIN as VATIN7_1_, this_1_.BusinessTypeClvId as Business5_7_1_, t= his_1_.StateClvId as StateClvId7_1_, this_1_.ContactInfoId as ContactI7_7_1= _, clientgrou1_.Id as Id16_0_,=20 clientgrou1_.ClientId as ClientId16_0_, clientgrou1_.ClientGroupClvId as Cl= ientGr3_16_0_, clientgrou1_.StartDate as StartDate16_0_, clientgrou1_.EndDa= te as EndDate16_0_,=20 clientgrou1_.StateClvId as StateClvId16_0_=20 FROM Client this_=20 inner join BusinessInfo this_1_ on this_.BusinessInfoId=3Dthis_1_.Id=20 inner join ClientGroup clientgrou1_ on this_.BusinessInfoId=3Dclientgrou1_.= ClientId WHERE clientgrou1_.Id in (60, 61) and this_1_.Name like 'Ett%' And the result is: Client 1 (ClientGroup info in the list: 60=092038=0918753=092007-03-05 16:4= 3:27.000=09NULL=0918753): 2038=09NULL=09NULL=09NULL=0918753=09NULL=09NULL=09NULL=09NULL=092007-03-05 = 16:43:27.000=09NULL=090=090=09Ettev=C3=B5tte nimi=09454545999.0=09EE9994545= 45=0918754=0918753=097215=0960=092038=0918753=092007-03-05 16:43:27.000=09N= ULL=0918753 Client 2: 2038=09NULL=09NULL=09NULL=0918753=09NULL=09NULL=09NULL=09NULL=092007-03-05 = 16:43:27.000=09NULL=090=090=09Ettev=C3=B5tte nimi=09454545999.0=09EE9994545= 45=0918754=0918753=097215=0961=092038=0918753=092007-03-05 16:43:27.000=09N= ULL=0918753 The only difference is the ClientGroup. I think the result in it self it co= rrect, but it seems to somehow map the information back wrong or ? The mapping files are the same. > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-03-06 15:02:45
|
[ http://jira.nhibernate.org/browse/NH-933?page=3Dall ] =20 Sergey Koshcheyev closed NH-933: -------------------------------- Resolution: Fixed > Expression.In does not support Generic lists > -------------------------------------------- > > Key: NH-933 > URL: http://jira.nhibernate.org/browse/NH-933 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.CR1 > Reporter: Taavi K=C3=B5osaar > Priority: Trivial > Fix For: 1.2.0.GA > > Expression.In takes only ICollection, but since generic lists come from I= Collection<T>, not from ICollection, it is not possible to put in generic l= ists.=20 > Perhaps a quick solution is to use IEnumerable as input type (IList<T> im= plements this inetrface, and so do most of the collection/array/List types)= ? > I did not find this to be reported anywhere. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |