My Date field in database is saved in nvarchar(10).Here I want compaire two date together This is my code:
public bool SalesFactorIsExist(IFeeKindDTO inFeeKindDTO)
{
bool isExist = false;
int count = 0;
var context = new SabzNegar01Entities1();
try
{
count = (from p in context.tbl_SalesFactor_D
where p.tbl_SalesFactor_M.tbl_Customer.CustomerGroupCode == inFeeKindDTO.CustomerGroupCode && p.StockCode == inFeeKindDTO.StockCode && ConvertStringDate(p.tbl_SalesFactor_M.FactorSalesDate) >= ConvertStringDate(inFeeKindDTO.StartDate)
select new { p.Row }).Count();
if (count != 0)
{
isExist = true;
}
}
catch (Exception ex)
{
PMessageBox.Show("خطا در خواندن اطلاعات", "اخطار", PMessageBoxButtons.Ok, PMessageBoxIcons.Error);
}
return isExist;
}
I have used from this method:
private DateTime ConvertStringDate(string inDate)
{
DateTime result = DateTime.Parse(inDate);
return result;
}
But there is an error:
LINQ to Entities does not recognize the method 'System.DateTime ConvertStringDate(System.String)' method, and this method cannot be translated into a store expression.
What should I do? Is there another way?