I have following query:
var query = from product in SH_Products
from product_group in SH_ProductGroups_Products.Where(c=>c.ProductID == product.ID)
from manufacturer in SH_Manufacturers.Where(c=>c.ID == product.ManufactureID)
from attributeOption_product in SH_AttributeOptions_Products.Where(c=>c.ProductID == product.ID).DefaultIfEmpty()
where !product.IsDeleted
&& !product_group.IsDeleted
&& !manufacturer.IsDeleted
&& product.Status != 0
select new
{
product.ID,
ProductGroupID = product_group.ProductGroupID,
AttributeOptionID = (int?)attributeOption_product.AttributeOptionsID,
product.ManufacturerID
};
query.Distinct().Dump();
Below is the sample output:
ID ProductGroupID AttributeOptionID ManufacturerID
1 1 75 1
1 1 76 1
2 3 17 2
3 2 3 1
4 1 NULL 1
As you see, we have 2 record with ID = 1
, and I don't wanna this, how I can remove this one?
I wrote this query for filtering section of my project.
I have filtering by ProductGroupID
, AttributeOptionID
, ManufacturerID
, all of them are multi-select-able !
thanks !