Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
If you are using .NET Core 5.0 or more you should be able to write something like the following (not tested): var data = context.TblOrder .OrderBy(o => o.OrderDate) .Select(o => ne...
Answer
#3: Post edited
If you are using .NET Core 5.0 or more you should be able to write something like the following:- ```c#
- var data = context.TblOrder
- .OrderBy(o => o.OrderDate)
- .Select(o => new
- {
- Order = o,
- OrderLines = o.TblOrderLine.OrderBy(ol => ol.ProductName)
- });
- ```
- The advantage of this approach is that you can specify the exact columns you need and the query will be more efficient (`Include` gets all the columns).[]()
- If you are using .NET Core 5.0 or more you should be able to write something like the following (not tested):
- ```c#
- var data = context.TblOrder
- .OrderBy(o => o.OrderDate)
- .Select(o => new
- {
- Order = o,
- OrderLines = o.TblOrderLine.OrderBy(ol => ol.ProductName)
- });
- ```
- The advantage of this approach is that you can specify the exact columns you need and the query will be more efficient (`Include` gets all the columns).[]()
#2: Post edited
- If you are using .NET Core 5.0 or more you should be able to write something like the following:
- ```c#
- var data = context.TblOrder
- .OrderBy(o => o.OrderDate)
- .Select(o => new
- {
- Order = o,
- OrderLines = o.TblOrderLine.OrderBy(ol => ol.ProductName)
- });
```
- If you are using .NET Core 5.0 or more you should be able to write something like the following:
- ```c#
- var data = context.TblOrder
- .OrderBy(o => o.OrderDate)
- .Select(o => new
- {
- Order = o,
- OrderLines = o.TblOrderLine.OrderBy(ol => ol.ProductName)
- });
- ```
- The advantage of this approach is that you can specify the exact columns you need and the query will be more efficient (`Include` gets all the columns).[]()