c# - LINQ to Entities - Support for Closures (Lambdas)? -


I am working around a problem, where I am closing LINQ using the units.

Obviously, L2E does not support closing meaning:

  var users = UserRepository.FindAll Select from user () New UserDTO {UserId = user.UserId, Tickets = Tickets for ticket in the ticket. FindAll () where ticket.User == User select new ticket item {ticket id = ticket takedown id}}; (Note: "Where" - The problem is where the problem exists. I am not allowed to compare an entity with any other entity because they are not EF primitive types. Only 32, Gid etc. are allowed.)  

, is not valid because I can not compare 'ticket' to the 'ticket' user

This is just an example of my problem , And I realize that I can compare it on ID because it is a primitive form Government is, as opposed to being off.

In reality my scenario is much more complicated than this, but this is the scenario that I need to solve now.

A work around I found online is using a subquery it works, but for my scenario this is not very effective.

Question:

None of you know that:

  1. units in framework 4, LINQ Will support Closer for?
  2. What is the better solution to this problem than using sub queries?
  3. Any additional knowledge you have on this topic will be highly appreciated!

    There is no problem directly related to closing it (probably) that the problem You are getting unit framework entities and your data transfer items, the LINQ provider tries to change the tree of expression of your query in the SQL query and fails because it can not separate data transfer objects from entities and databases, of course , Data transfer object T can not handle it too.

    I suggest making separation very cleaner - first can get data from the database using the unit from LINQ and if possible obtain data of anonymous forms, then from the reloaded data To create Data Transfer Objects, switch objects to LINQ and fix all. Something like the following (just to note - I am accepting the (safe) repository IQueryable s (otherwise all things should not work at all).

    User Repository. FindAll (). Select (user => New {UserId = user.UserId, TicketIds = TicketRepository .FindAll (). Where (ticket = & gt; ; Ticket.User.UserId == user.UserId). Select (Ticket => Ticket.Ticket ID)});

Transfer this query result as a data transfer object Rm is now unable to directly further note that comparisons are made by the user ID, because by comparison Antiti Framework (yet) context.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -