Can't get EntityFunctions.TruncateTime() to work

前端 未结 3 1566
Happy的楠姐
Happy的楠姐 2020-12-05 04:15

I am using Entity Framework Code First. Using LINQ to Entity I want to grab a record based on a DateTime value. Here is my current code:

/// 
         


        
3条回答
  •  鱼传尺愫
    2020-12-05 05:00

    DateTime? dt = DateTime.Parse(sText);
    campaigns = _CampaignMasterRepository.Get().OrderByDescending(a => a.LaunchOn).Where(a => a.UserId == obj_User.ID && a.CampaignStatus == (int)OmevoEnums.CampaignStatus.Sent && a.CampaignName.Contains(sText) || DbFunctions.TruncateTime(a.LaunchOn) == DbFunctions.TruncateTime(dt)).ToList();
    

    For getting the date results through Linq queries use this function.

提交回复
热议问题