score:2
Accepted answer
var employee = db.employee.where(x => x.employeeid == id ).
select(e => new { e.employeeid, e.firstname, e.lastname, e.dob, e.department.departmentname }).
asenumerable().
select(b => new
{
id = b.employeeid,
name = b.firstname + " " + b.lastname,
age = calculateage(b.dob.tostring()),
department = b.departmentname
} ).tolist();
if employee != null)
{
dgvemployee.datasource = employee;
}
Source: stackoverflow.com
Related Query
- LINQ to Entities does not recognize the method Int32 get_Item(Int32)
- linq to entities does not recognize the method int32 toint32
- LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression
- LINQ to Entities does not recognize the method
- LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object, System.Object)'
- LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method
- LINQ to Entities does not recognize the method 'System.DateTime GetValueOrDefault()'
- Why LINQ to Entities does not recognize the method 'System.String ToString()?
- LINQ to Entities does not recognize the method 'System.Linq.IQueryable`
- LINQ to Entities does not recognize the method 'System.DateTime AddSeconds(Double)' method, and this method cannot be translated into
- LINQ to Entities does not recognize the method 'System.Object GetValue(...)'
- LINQ to Entities does not recognize the method 'Int32 Int32(System.String)' method, and this method cannot be translated into a store expression
- LINQ to Entities does not recognize the method ElementAt(i);
- LINQ to Entities does not recognize the method 'System.String StringConvert(System.Nullable`1[System.Double])
- LINQ to Entities does not recognize the method 'Int32 ToInt32(System.Object)' method, and this method cannot be translated into a store expression
- LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method
- LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression
- LINQ to Entities does not recognize the method 'System.String get_Item(System.String)' method
- LINQ to Entities does not recognize the method 'System.String[] Split(Char[])' method,
- LINQ to Entities does not recognize the method 'System.String Format
- LINQ to Entities does not recognize the method Generic.List(int) to Generic.IEnumerable(int) method
- LINQ to Entities does not recognize the method exception
- LINQ to Entities does not recognize the method 'Method name' method
- LINQ to Entities does not recognize the method 'Int32
- LINQ to Entities does not recognize the method 'Boolean HasFlag(System.Enum)' when creating the expression via System.Linq.Expressions.Expression
- LINQ to Entities does not recognize the method 'System.Object Parse(System.Type, System.String)'
- LINQ to Entities does not recognize the method 'Newtonsoft.Json.Linq.JToken get_Item(System.String)' method,
- LINQ to Entities does not recognize the method 'System.Collections.Generic.Dictionary`2[System.Int32,System.String] ToDictionary
- LINQ to Entities does not recognize the method 'Boolean Exists(System.Predicate`1[Entities.Connection])' method
- error: LINQ to Entities does not recognize the method DataLength
More Query from same tag
- Filter entities, then sort on dynamic field
- how to use group by LINQ
- LINQ | How do I get SUM without grouping?
- Using string.compare in a linq query where clause
- LINQ: When to use 'new' in Select clause?
- Count Distinct - Inner Join - Group By / With the new Linq-to-NHibernate Provider
- Multiple Databases in ASP.NET MVC
- Entity Framework Exception in Foreign Key 2
- two conditions checking in where clause using linq 2 entites
- Is there a way I can do a foreach that contains code in a LINQ expression?
- Equal on Linq query
- Linq: Convert datatable rows to Dictionary<string, Dictionary<string, string>>
- Dynamic Lambda Select Index
- XML LINQ: How to select more than one item?
- join two tables with multiple condition in linq
- Compare array with TextBox to check for repeated values in database
- System.InvalidOperationException: 'The LINQ expression could not be translated. Either rewrite the query in a form that can be translated
- Update Datatable with another
- Linq Lambda expression - left join
- find the child entities with specific property in Entity Framework
- Create MemberExpression from a navigation property selector string, C#?
- Change to linq left join query
- Double(,) and not Double()() from DataTable Using Select
- Most efficient way to check to see if there is any data in a SQL row
- Dynamically building LINQ queries from string
- How to Filter out null rows from DataTable with linq?
- Search functionality across many columns
- Linq or Lambda - Method to allow custom Orderby clause on joined table
- How to optimize this LINQ expression?
- How to group by with left join by multiple columns using linq and get count of grouped records?