var query = _context.POS_ItemPriceListMaster.Where(c => c.FromDate >= FromDate && c.ToDate <= FromDate).Select(t=> t.ItemPriceListMasterID);
var query2 = from c in _context.POS_ItemPriceList
where query.Contains(c.ItemPriceListMasterID)
select c;
I want to do this but there are no result in query although there are data with from date In database field is datetime
我想这样做,但是查询没有结果,尽管数据库字段中的数据是datetime
1 个解决方案
#1
0
I assume c.FromDate
and c.ToDate
are dates without time information and FromDate
is a date with time information.
我认为c。FromDate和c。ToDate是没有时间信息的日期,FromDate是一个具有时间信息的日期。
To fix your query, remove the time from FromDate
:
要修复查询,请从日期中删除时间:
var fromDateWithoutTime = FromDate.Date;
var query = _context.POS_ItemPriceListMaster
.Where(c => c.FromDate >= fromDateWithoutTime
&& c.ToDate <= fromDateWithoutTime)
.Select(t=> t.ItemPriceListMasterID);
#1
0
I assume c.FromDate
and c.ToDate
are dates without time information and FromDate
is a date with time information.
我认为c。FromDate和c。ToDate是没有时间信息的日期,FromDate是一个具有时间信息的日期。
To fix your query, remove the time from FromDate
:
要修复查询,请从日期中删除时间:
var fromDateWithoutTime = FromDate.Date;
var query = _context.POS_ItemPriceListMaster
.Where(c => c.FromDate >= fromDateWithoutTime
&& c.ToDate <= fromDateWithoutTime)
.Select(t=> t.ItemPriceListMasterID);