|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-06-09 12:10:21
|
[ http://216.121.112.228/browse/NH-2762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo updated NH-2762:
----------------------------
Affects Version/s: (was: 3.2.0Beta2)
(was: 3.2.0Beta1)
(was: 3.2.0Alpha3)
(was: 3.2.0Alpha2)
(was: 3.2.0Alpha1)
(was: 3.0.0.GA)
(was: 3.0.0.CR1)
(was: 3.0.0.Beta2)
(was: 3.0.0.Beta1)
(was: 3.0.0.Alpha3)
(was: 3.0.0.Alpha2)
(was: 2.1.2.GA)
(was: 2.1.1.GA)
(was: 3.0.0.Alpha1)
(was: 2.0.1.GA)
(was: 1.2.1)
Just as curiosity.
I saw you have reported the issue even for version 1.2.0 that was released some years ago when LINQ was, perhaps, not even just an idea for some Microsoft guy.
Are you doing it for some special reason or is just to do something cool ?
> Failed to use IGrouping<TKey, TElement>.Contains() from Lookup to make SQL IN statement
> ---------------------------------------------------------------------------------------
>
> Key: NH-2762
> URL: http://216.121.112.228/browse/NH-2762
> Project: NHibernate
> Issue Type: Bug
> Components: Linq Provider
> Affects Versions: 3.1.0
> Reporter: Mazlan
> Priority: Minor
> Attachments: NH2762.zip
>
>
> This bug still happened in current Revision 5914.
> Using array, List or collection does not have a problem to make SQL IN statement by using Contains() method.
> However NHibernate does not generete SQL IN statement from IGrouping<TKey, TElement> type which is mostly used from ILookup<TKey, TElement>.
> It simply pass it to SQL parameter which then will cause GenericADOException.
> Reproduce:
> var Emps = (from e in s.Query<Employee>()
> select e).ToList();
> var EmpsInDept = Emps.ToLookup(e => e.Department, e => e.Id); // e.Department is a type of string.
> foreach (var DeptGroup in EmpsInDept)
> {
> if (DeptGroup.Key == "IT")
> {
> var firstNameInIT = (from e in s.Query<Employee>()
> where DeptGroup.Contains(e.Id)
> select e.FirstName).ToList();
> }
> }
> The "DeptGroup.Contains(e.Id)" will throw the exception. Currently convert it to a List temporarily fix it "DeptGroup.ToList().Contains(e.Id)".
> Note:
> IGrouping<TKey, TElement> is also IEnumerable<TElement> which can be used like this:
> List<string> list = new List<string>(DeptGroup);
> foreach (string dept in DeptGroup){}
> because DeptGroup is also implement IEnumerable<TElement> which is IEnumerable<string>
> Suggestion: to build the SQL IN statement do not only look for collection, List or Array type but also any of IEnumerable<TElement> with method Contains().
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|