I'll be the first to admit I'm no Linq genius (hardly), but I'm
thinking the deferred execution of the whole thing ultimately has the
"new" op showing up in the where clause. If I have this right it's
essentially doing the following query:
var me = from u in _db.Users
where u.Status == "active" && new User(u).Name == "Abe"
select new User(u);
Don't worry, I'm using DI to send the database context into the
constructor. I just threw the example together ... not even sure if
it would compile.
-Abe
On Thu, Jun 24, 2010 at 1:40 PM, Jonathan Pryor <[email protected]> wrote:
> I may be crazy, or blind, but in your revised sample I don't see where
> you're attempting to use 'new' within a .Where(), the only uses of
> 'where' I see are in DbLinqUserRepository.GetAll():
>
> where u.Status == "active"
>
> and in Program.Main():
>
> var abe = userRepo.GetAll()
> .Where(u => u.Name == "Abe").SingleOrDefault();
>
> Both of these should be fine.
>
> As an aside, be very careful about storing a DataContext in a class
> member; it can be problematic (see the list archives).
>
> Specifically, in both your examples you're comparing to a string, which
> SHOULD work (and doesn't rely on ExpressionType.New) and is used
> ~everywhere in the unit tests, so I think your example is still omitting
> something.
>
> As for fixing quickly, there don't seem to be too many people working on
> the project of late, so I'm not sure who you could ask.
>
> As for fixing it yourself, I would suggest looking at
> AnalyzeNewOperator() in
> src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionDispatcher.Analyzer.cs,
> as that's what handles 'new' expressions within the .Select() extension
> method support. You might be able to reuse/repurpose some of that logic
> for use by .Where()...
>
> - Jon
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "DbLinq" 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/dblinq?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"DbLinq" 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/dblinq?hl=en.