0
点赞
收藏
分享

微信扫一扫

在LINQ中,在where条件中如何使用Int?或decimal?


var queryResult = (from schedule in GetAll<EziScheduleEntity>()
where
schedule.StartTime < endTime &&
schedule.EndTime > startTime &&
(!SiteId.HasValue || schedule.SiteId == SiteId)
select schedule
);


实例:

在LINQ中,在where条件中如何使用Int?或decimal?_Linq

 public List QueryTradeQMnInfo(QMnInfo info, DateTime startTime, DateTime endTime, int pageIndex, int pageSize, out int totalCount)

       {

           Session.Clear();

           var query = from a in this.Session.Query<QMnInfo>()

                       where (info.BusniessType == string.Empty || info.BusniessType == a.BusniessType) &&

                       (string.IsNullOrEmpty(info.UserId) || info.UserId == a.UserId) &&

                       (!info.Quantity.HasValue || a.Quantity >= info.Quantity) && (!info.Amount.HasValue || a.Amount >= info.Amount) &&

                       (string.IsNullOrEmpty(info.TradeType) || info.TradeType == a.TradeType) &&

                       (string.IsNullOrEmpty(info.IpArddess) || info.IpArddess == a.IpArddess) &&

                       (string.IsNullOrEmpty(info.CompletionStatus) || info.CompletionStatus == a.CompletionStatus) &&

                       a.CreateTime >= startTime && a.CreateTime <= endTime

                       orderby a.CreateTime descending

                       select a;

           totalCount = query.Count();

           return query.Skip(pageIndex * pageSize).Take(pageSize).ToList();

       }

举报

相关推荐

0 条评论