Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try to select all unique (expired dates) with distinct() :

gridView3.Columns[0].FieldName = "pis_ExpireDate";

var EXdates = DB0201.purchases_item_seriels.Where(u => (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 0) ||
                                                                                (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 5) ||
                                                                                (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 6))
                                                                                .OrderBy(o => o.pis_ExpireDate).Select(u => u.pis_ExpireDate).Distinct(); 

    gridControl3.DataSource = EXdates.ToList();

rows created but no data appears!!

What I have tried:

i tried to select all data without Select(u => u.pis_ExpireDate) , it work

gridView3.Columns[0].FieldName = "pis_ExpireDate";

var EXdates = DB0201.purchases_item_seriels.Where(u => (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 0) ||
                                                                                (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 5) ||
                                                                                (u.stitems_ID == ItemID && u.ss_StoreID == StoreID && u.pis_Statues == 6))
                                                                                .OrderBy(o => o.pis_ExpiraeDate);
    gridControl3.DataSource = EXdates.ToList();

rows created and all data appear but without merge
Posted
Updated 29-Nov-18 9:40am
v2
Comments
F-ES Sitecore 26-Nov-18 6:10am    
With your first query you are selecting a list of a single field (pis_ExpireDate) so it'll be a list of whatever type that is (DateTime or whatever). In the second query you are returning a list of purchases_item_serial objects. I assume you actually want a list of distinct purchases_item_serial objects and not just a list of dates. Update the question to provide a sample of your data and what your desired output is.
Golden Basim 26-Nov-18 6:50am    
i need to show only list of expired dates in Gridview , i use this line to define the first column field name :
gridView3.Columns[0].FieldName = "pis_ExpireDate";
F-ES Sitecore 26-Nov-18 6:58am    
You're creating a list of DateTime variables so there is so such thing as a field called pis_ExpireDate, that's just the property the data originally came from. You'll probably need to do something like this;

Select(u => new { pis_ExpireDate = u.pis_ExpireDate })

that will create a list of anonymous objects with a property called pis_ExpireDate so your gridview will be able to reference the data by property name. The Distinct might stop working though as it has no way of working out if the objects are distinct, you might need to google how you can do a custom Distinct for your objects.
Golden Basim 26-Nov-18 11:26am    
thank you , it work after changing to .Select(u => new { u.pis_ExpireDate }) thanks
ZurdoDev 29-Nov-18 15:37pm    
Please post as solution.

1 solution

thank you , it work after changing to
.Select(u => new { u.pis_ExpireDate })
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900