|
From: Mazlan (JIRA) <nh...@gm...> - 2011-06-08 10:22:15
|
[ http://216.121.112.228/browse/NH-2762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mazlan updated NH-2762:
-----------------------
Attachment: NH2762.zip
Here is the test, GroupingContains() will failed while the rest is ok.
> 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: 1.2.1, 2.0.1.GA, 2.1.1.GA, 2.1.2.GA, 3.0.0.Alpha1, 3.0.0.Alpha2, 3.0.0.Alpha3, 3.0.0.Beta1, 3.0.0.Beta2, 3.0.0.CR1, 3.0.0.GA, 3.1.0, 3.2.0Alpha1, 3.2.0Alpha2, 3.2.0Alpha3, 3.2.0Beta1, 3.2.0Beta2
> 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
|