I have one table with name CateringPurchaseOrder. That table contains one column with name "PONO". that column contains same vlaue more than once. I want to retrieve record based on the unique value in "pono" column.
Example:
pono column1
1 value1
1 value2
2 value3
2 value4
output:
pono coulm1
1 value1
2 value3
I have tried with the following code:
IEnumerable<CateringPurchaseOrder> order = entites.CateringPurchaseOrders.Distinct<CateringPurchaseOrder>(new CateringPorderComparer());
public class CateringPorderComparer : IEqualityComparer<CateringPurchaseOrder>
{
bool IEqualityComparer<CateringPurchaseOrder>.Equals(CateringPurchaseOrder p1, CateringPurchaseOrder p2)
{
return p1.P_O_No == p2.P_O_No;
}
int IEqualityComparer<CateringPurchaseOrder>.GetHashCode(CateringPurchaseOrder obj)
{
return obj.P_O_No.GetHashCode();
}
}
I got the following error:
LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[MilitarymessModel.CateringPurchaseOrder] Distinct[CateringPurchaseOrder](System.Linq.IQueryable`1[MilitarymessModel.CateringPurchaseOrder], System.Collections.Generic.IEqualityComparer`1[MilitarymessModel.CateringPurchaseOrder])' method, and this method cannot be translated into a store expression.
Do you have solution for this problem?