score:1
You can't use regular function calls in a query definition like that. LINQ needs expression trees, it can't analyze compiled functions and magically translate that to SQL. Read this for a more elaborate explanation
The techniques used in the cited article are incorporated in linqkit (factoring out predicates) and might be of help, though I'm not sure you can use the same technique for managing projections, which is what you seem to want.
The more fundamental question you should ask yourself here IMHO is whether you really need this extra mapping layer? It seems like you're implementing something that EF is already perfectly capable of doing for you...
score:0
Try making your MapUser
method static
.
Source: stackoverflow.com
Related Articles
- Using async with Entity Framework select list of type IQueryable<T>
- SELECT NEW with a potentially null field using LINQ and Entity Framework
- Wrong select query generated with Entity Framework (mysterious extra column)
- ASP NET CORE Entity Framework Select with GroupBy Id
- Select data from multiple unrelated tables with LINQ to Entity Framework
- How do you re-use select statements with Entity Framework?
- Entity Framework Code First String Comparison with Oracle Db
- SELECT UNTIL in SQL with Entity Framework
- most efficient Entity Framework Code First method of flattening / projecting parent entity with specific child
- Using custom method inside Linq Select with Entity Framework
- Entity Framework Select Statement with Logic
- Select Top for Subquery with Entity Framework
- Entity Framework select object with grandparent ID
- Net Core: Entity Framework ThenInclude with Projection Select
- Code First Entity Framework, select ViewModel - constructor with parameter
- Entity Framework Core Select Property with multiple conditions
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- How to Lazy Load child object with string primary key in Entity Framework Code First?
- map one to one with multiple primary key columns entity framework code first
- How to select a query with multiple columns and put it into variables using Entity Framework and ASP.NET?
- In Entity Framework Core, with one query, how do I select objects by the order of a parent object?
- How to select elements from a table that are present in a junction table with LINQ - Entity Framework
- Hierarchical select in Entity Framework with lambda expression
- How to select multiple columns with entity framework and display it with textBlocks?
- Entity framework select all related items in fact table with condition in dimension table
- Linq with entity Framework using a function to select columns
- Entity Framework Code First Select Item Based on Relationship
- How to select specific columns in one-to-one relationship table along with few direct columns in Entity Framework Fluent API
- Entity Framework - Select Single Column with Null Check
- Linq Entity Framework select distinct with aggregate columns
- Linq datatable does not contain the definition of AsParallel C#?
- Search DataRow with Linq and delete from Dataset
- Assigning values in group of Labels by using LINQ
- I have an array, I want to find some element
- SQL Server query to C# Linq
- Can we control LINQ expression order with Skip(), Take() and OrderBy()
- ASP MVC 3 - Bind multi table linq query to gridview and export to .xls
- Unable to create a constant value of type ' ' . Only primitive types or enumeration types are supported in this context
- Returning IEnumerable<T> vs. IQueryable<T>
- two foreach in linq?
- Copying a row from one table to another using LINQ and C#
- How do I search just the children of an XDocument, rather than all of its descendants?
- Linq Multiple Joins to SelectList
- Transform Row Data to Columns in Linq
- Linq to Excel - only recieving data from last row in sheet1
- How to cast an IEnumerable<object> to an IEnumerable<runtime type>
- Is it a clean way to write this function?
- C# - How to loop back around after assigning integer IDs from a collection?
- LINQ to SQL join tables special blend
- Mapping Linq Group By Results To An Object