score:3
yes, you can do:
expression<func<person, personentity>> converttopersonentity() {
return x => new personentity { id = x.id, name = x.name };
}
...and then:
personentity getbyid(int id) {
var exp = converttopersonentity();
return db.person.firstordefault(exp);
}
Source: stackoverflow.com
Related Query
- EF: Can I have single point for lambda to class instance conversion?
- Create Lambda Expression Selector For New Class Using Expression Tree
- Convert or map a class instance to a list of another one by using Lambda or LINQ?
- How can I Pass in a lambda that will be used as a filter for a row in a datatable?
- Using LINQ how can I check for an instance of a number in one array, in another array?
- What can be the code for someIEnumerable.Select extension method?
- Lambda Expression for Many to Many realtionship in C# EF 5 Code First
- How can I refactor this code for LINQ filtering?
- Can I use a LINQ IEnumerable result as the data source for a Gtk.TreeView?
- If I have a collection of classes how can I return a collection of a single attribute of all the classes?
- Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?
- Is it possible to have one LINQ in one line of code for
- source code for LINQ 101 samples
- Can I Use The Same Linq Code to Query for Different Conditions?
- ForEach loop with Lambda expression in Razor code MVC 5 For List<T>
- generic class for linq / lambda expression
- How can I merge time entries into a single row for a weekly report?
- What can be Short cut Code for following
- Create a C# Generic class for repeated code
- How can I return a single value integer from Linq from an array of objects that have other nested values
- Error : The ObjectContext instance has been disposed and can no longer be used for operations that require a connection
- How I can improve the code using lambda expressions?
- Can I query all the boolean properties on a C# object at once, looking for a single match?
- The ObjectContext instance has been disposed and can no longer be used for operations that require a connection
- Least code to convert one object to anothe for both single object and List<object>?
- How can I create an Lambda Expression for Linq in the Where clause for two tables after the Join?
- How can I Merge Two LINQ DataSources into a single table for a chart?
- Implicit operators, Linq and Lambda expressions can make code less readable. But what is more readable?
- c# Linq or code to extract groups from a single list of source data
- Entity to LINQ upload CSV file where single rows can have multiple values in columns
More Query from same tag
- Event when HttpRequest Ends?
- Using Linq to merge to List
- Use == operator with generic type in a Where Linq statement
- How can I express GetDate() and DateAdd() methods in EF Core and LINQ?
- C# Linq Select Rows Where ID Equals ID in CSV
- In LINQPad can you access SYSOBJECTS using LINQ?
- Linq: Model does not bind properly to Database View(query with UNION)
- Matching 2 lists in Linq to Entities
- interface design with Linq2Nibernate and IQueryable
- Using LINQ with a WHERE to ask for multiple possible results without redundant "||" commands
- date comparison in EF query
- LINQ GroupBy to get Name and A Count
- c# Leaner way of initializing int array
- LINQ group by date descending, and order by time ascending
- Problem with Linq query .net MVC
- Linq how to select only a small subset of a large result set?
- Group by variable integer range using Linq
- linq join question
- How to get repeated values in LINQ
- Dropdown bind method not working
- Select objects in binding list that match criteria using LINQ?
- Extending Func to accept array parameter in C#
- handle null query c# when equals null, Object reference not set to an instance of an object
- Custom LINQ Method into a store expression for re-usability and scaling later
- get Node by it's attribute in linq to xml
- Convert Timespan to string in LINQ
- C# query basic BSON knowing only key and values using LINQ
- LINQ to Entities, join two tables, then group and take sums of columns from both tables
- How can I improve LINQ?
- Returning the correct type in C# linq query over DataRows