score:0
i'd use a select
to get the entities with orderby after the where
but before firstordefaultasync()
. like this:
var header = await _context.headers
.include(location => location.headerlocation)
.include(details => details.details)
.where(p => p.headerid == headerid)
.select(header => new header
{
// assign header values
location = header.location,
details = header.details.orderby(h => h.fieldname).orderby(h => h.lineversion)
}).firstordefaultasync();
score:2
on top of the other suggestion i have seen, i used the link in the comments of the original post, and got a great answer there, too. i tested it, and it works like a charm. here is what i ended up with:
public async task<permitheader> getpermit(int headerid)
{
var header = await _context.headers
.include(location => location.location)
.where(p => p.headerid == headerid).firstordefaultasync();
var details = await _context.details
.orderby(ob => ob.fieldname)
.orderby(ob => ob.lineversion)
.where(d => d.headerheaderid == headerid).tolistasync();
header.details = details;
return header;
}
thanks for a quick response!
Source: stackoverflow.com
Related Query
- Lambda expression used inside Include is not valid
- Lambda expression used inside Include is not valid. EF6, Navigation Property
- EF Core Filtered Include: "Lambda expression used inside Include is not valid"
- 'The LINQ expression node type 'Invoke' is not supported in LINQ to Entities' when lambda is passed as a parameter, but not when used directly
- An expression tree lambda may not contain a null propagating operator
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- Cannot convert lambda expression to type 'object' because it is not a delegate type
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- C# multiple variables in lambda expression inside LinQ query
- "Does Not Contain" dynamic lambda expression
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- Assigning a lambda expression causes it to not be executed later?
- Include using Lambda expression
- Cannot convert lambda expression to type 'string' because it is not a delegate type - OrderBy and DbGeography by ref
- "Cannot convert lambda expression to type 'string' because it is not a delegate type" querying dataset in C#
- C# Lambda Expression not returning expected result
- Where condition inside lambda expression c#
- linq to entity - include with lambda expression
- Dynamic Lambda Expression inside an Expression Query
- How to Solve this Error "Cannot convert lambda expression to type 'string' because it is not a delegate type"
- LINQ operater Where not supporting any of the members when used inside generic method
- Cannot convert lambda expression to type 'bool' because it is not a delegate type
- Lambda expression to grab all values inside a Dictionary
- Lambda Expression with a statement body can not been converted
- Error "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities" in where clause inside the method
- The Include property lambda expression [...] is invalid. The expression should represent a property access
- LINQ to Entities does not recognize method inside an Expression
- Lambda Expression for Many to Many realtionship in C# EF 5 Code First
- Cannot convert lambda expression to type int because it is not a delegate type
More Query from same tag
- Linq group string array by count and sort
- How do I linq like query with Dictionary in typescript?
- How remove empty element from string array in one line?
- Can you add an If Statement in a LINQ(XML) query?
- LINQ lambda for many to many relationship
- Weird LINQ ToList(), IEnumerable vs AsQueryable() results
- how to write code to find element in directory in Linq
- Get rid of non-digits and then get last n chars of a string in LINQ
- C# generic method for multiple classes
- Linq To Sql Get data into Label
- I cant return a value with system.linq.IQueryable, Is there any way?
- nullable model field in LINQ
- Cannot apply indexing with [] to an expression of type 'method group' SinglePageApp1. Get["/"] Nancy
- LINQ query to return whether an item is found in an array?
- LINQ query for string.replace
- LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'
- How to join using complex expression using Linq2Sql C# Expressions
- Internal access for entities in Entity Framework makes simple linq where query crash
- Get only unique elements from a list
- Get single value list of Company Codes for Combobox
- Exception thrown when accessing DBContext from unit test
- How can I get this result using linq?
- How do I make a LINQ expression to call a method?
- Anonymous Type Appears in both Error
- Covert SQL to Linq Query
- Percentage in LINQ comes out as zero
- Send E-mail reminder with ASP.NET
- Recursively remove xml nodes using Linq to XML
- How can I query an XDocument with a 'path'?
- Linq Select 5 items per Iteration