|
From: Mazlan (JIRA) <nh...@gm...> - 2011-06-10 03:21:28
|
[ http://216.121.112.228/browse/NH-2762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21279#action_21279 ]
Mazlan commented on NH-2762:
----------------------------
:) Emm...it not only affect v3.1 but until the nightly build release.
I create the test project which I attached above and tested from the current trunk.
It was failed at least in my last checkout reversion 5914, so the new v3.2 beta also the same.
Good luck.
> 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
|