C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,546 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am getting values from various form inputs and trying to dynamically construct the where clause. I couldn't find a way to, unfortunately. Hope you can help.
Here is
public async Task<IEnumerable<Order>> GetOrdersForExport(int vendorId,string status, DateTime? startDateTime, DateTime? endDateTime)
{
var result = from order in _db.Orders
from orderDetail in _db.OrdersDetail on order.Id equals orderdetail.OrderId
from vendor in _db.Vendors on orderdetail.VendorId equals vendor.Id
select new {order, orderdetail, vendor} ;
if (vendorId != null)
{
}
return await result;
}
Here is the relations
Do you mean something like this?
Hi @Viorel , thank you for your reply.
When I write it in the linqpad it gives an error. Is it related with linqpad?
I got rid of my first reply was having issues with the editor
Hi @Karen Payne MVP , Thank you for your help. I changed the query to method linq in order to return Task in my method. But the problem is how to get vendor in the where clause since OrderDetails is a list.
Does this work?
Because of joining with OrderDetails, the result increases the data. Notice the Ids in the picture. How can I retrieve without duplicating data?
@Cenk , If you want to retrieve without duplicating data, you could try to use Distinct method to do it.
Sign in to comment