Reputation: 355
I am using my linq query as below
var result = from m in genDB.Membership_Association
join ag in genDB.Account_Group on m.Account_Group_ID equals ag.Account_Group_ID
join s in genDB.Account_Section on m.Account_Section_ID equals s.Account_Section_ID
join p in genDB.Account_Package on m.Account_Package_ID equals p.Account_Package_ID
join pinfo in genDB.ProductInfo on m.Product_ID equals pinfo.Product_Id
where m.Control_Plan_ID == controlPlanId && m.Account_ID == accId
select new MembershipViewModel
{
GroupNumber = ag.Account_Group_Number,
SectionNumber = s.Account_Section_Number,
PackageNumber = p.Account_Package_Number,
ProductName = pinfo.Product_Name,
CreatedDate = m.Create_Date.Date,
EffectiveDate = m.Effective_Date.Value.Date,
CancelledDate = m.Cancel_Date.Value.Date,
Status = m.Status
};
In the above query, it is throwing an exception "The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported." at .Date prperty
Upvotes: 1
Views: 361
Reputation: 1347
You need to make sure that you are comparing only the Date part both side.
Test cases:
4.If it is date type, check it with date type. For example,
var query = from e in db.MyTable where e.AsOfDate <= DateTime.Now.Date select e;
Atleast you will be able to go near the solution if you tried it.
Most probably you might have to do like this in your code:
CreatedDate.Date = m.Create_Date.Date
Upvotes: 1
Reputation: 39297
You can use SqlFunctions.DatePart
to extract the relevant parts of the DateTime that you want to compare. See http://msdn.microsoft.com/en-us/library/system.data.objects.sqlclient.sqlfunctions.datepart.aspx
Upvotes: 0