Why do that when you can just use an anonymous type?
var repository = from u in db.Users select new { Key = u.Name, Value =
u.RegisteredAt);
var query = repository.OrderBy(x => x.Value).Skip(0).Take(2);
var list = query.ToList();
On Dec 18, 9:17 pm, mago99 <[email protected]> wrote:
> On a project I'm working with Linq to Nhibernate3, I'm getting an
> exception, System.NotSupportedException : NewExpression . The
> following steps will reproduce the exception:
>
> 1. Steps to reproduce
>
> Append the
> "will_fail_when_a_projection_and_a_dynamic_orderby_are_used" test to
> DynamicQueryTests.cs from NHibernate.Test project and run it.
>
> System.NotSupportedException : NewExpression
>
> [Test]
> public void
> will_fail_when_a_projection_and_a_dynamic_orderby_are_used() {
> var queryRepository = from u in db.Users select new
> KeyValuePair<string, DateTime>(u.Name, u.RegisteredAt);
>
> var queryController = queryRepository.OrderBy("Value").Skip((0)
> * 2).Take(2);
>
> var list = queryController.ToList();
>
> Assert.True(list.Count > 0);
> }
>
> 2. What you expected to see.
>
> I was expecting to see a list of KeyValuePairs.
>
> 3. What you saw instead.
>
> What I saw instead was, the exception System.NotSupportedException :
> NewExpression.
>
> 4. What do I want
>
> I will like to know if I'm getting the exception because there's a bug
> in L2NH, or it;s a limitation on the L2NH provider or am I doing
> something wrong?.
>
> Thanks for your help,
>
> Mauricio
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.