LINQ to Entities中两次的时差?

时间:2015-01-20 18:58:14

标签: c# entity-framework linq-to-entities

var TimeNow = DateTime.Now.TimeOfDay;

var qq = from s in _EeHC_HrEntities.TransactionsSecretaries
         where (EntityFunctions.CreateTime(s.TransactionTime.Hours,
                                           s.TransactionTime.Minutes,
                                           s.TransactionTime.Seconds) >
                EntityFunctions.CreateTime(TimeNow.Hours,
                                           TimeNow.Minutes,
                                           TimeNow.Seconds))

我希望在两次之间进行比较,并在dataebase>中显示data.time的数据。 DateTimeNow.time但结果显示为True

1 个答案:

答案 0 :(得分:0)

**becouse th 24 hours convert to 12 hours it will work thanx for answers** 

var TimeNow = DateTime.Now.TimeOfDay;
    var TimeHourNow = (TimeNow.Hours < 12) ? TimeNow.Hours : (TimeNow.Hours - 12);


var qq = from s in _EeHC_HrEntities.TransactionsSecretaries
         where (EntityFunctions.CreateTime(s.TransactionTime.Hours, s.TransactionTime.Minutes, s.TransactionTime.Seconds) > EntityFunctions.CreateTime(TimeHourNow, TimeNow.Minutes, TimeNow.Seconds))