I need help converting SQL query to LINQ to SQL
select top 5 customer_id, customer_name, product_id
from Customer
Join Product on product_id = product_id
where (customer_active = 'TRUE')
order by checksum(newid())
How can I do that in LINQ to SQL. Thanks
try this code
you should use this way to remove Boolean condition and reduce code
if you need to check bool condition in Ef
1.For True Condition db.Customer.Where(p => p.customer_active).select(m=>m).tolist(); 1.For False Condition db.Customer.Where(p => !p.customer_active).select(m=>m).tolist();
just for suggestion
This was solved. Thanks to 'CodeNotFound' for this answer https://stackoverflow.com/a/43850748/1655774