How to Get objects by many ids in Linq-to-Nhibernate

233 views
Skip to first unread message

Arman

unread,
Oct 19, 2011, 12:51:51 PM10/19/11
to nhusers
Hi,

how can i get more than one object with a list of id's ?

is there any overload of Session.Get with (Array of object) to load
more than one object at the same time ?

is there any work around for it in Linq to Nhibernate??

also, there is a limitation in t-sql in parameters count , so Since
nhibernate linq create sql queries with parameters , so that we cannot
load more than an specific amount of objects by time.
is there any workaround to this too?

Gunnar Liljas

unread,
Oct 19, 2011, 2:23:25 PM10/19/11
to nhu...@googlegroups.com
No, there is no overload, but all query types support list parameters, so that's covered.

e.g (x=>myList.Contains(x.Id))

AFAIK, there is no workaround for the parameter limit. I made a workaround in a Linq2Sql project once, which was based around a derived DbConnection/DbCommand class. By overriding the Execute methods and effectively "deparametrize" all IN criteria I was able to work around the limit. The same thing would be possible with a custom NHibernate provider.

/G

2011/10/19 Arman <arman....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.


Arman

unread,
Oct 19, 2011, 3:22:18 PM10/19/11
to nhusers
Thanks for your reply,

Can i use subquery in this situation? i mean use another IQueryable
into another IQueryable ?



On Oct 19, 9:23 pm, Gunnar Liljas <gunnar.lil...@gmail.com> wrote:
> No, there is no overload, but all query types support list parameters, so
> that's covered.
>
> e.g (x=>myList.Contains(x.Id))
>
> AFAIK, there is no workaround for the parameter limit. I made a workaround
> in a Linq2Sql project once, which was based around a derived
> DbConnection/DbCommand class. By overriding the Execute methods and
> effectively "deparametrize" all IN criteria I was able to work around the
> limit. The same thing would be possible with a custom NHibernate provider.
>
> /G
>
> 2011/10/19 Arman <arman.naj...@gmail.com>

Arman

unread,
Oct 20, 2011, 6:14:59 AM10/20/11
to nhusers
BTW, i solved the problem with a join query.

Thanks a lot,
Reply all
Reply to author
Forward
0 new messages