我有这个错误不能<short>
在这行代码中隐式地将 Enumerable 行集合转换为短:
Month = (from item in query select (short)item.Month);
我想知道为什么以及为什么在查询变量中找不到 distinct() 或 count 方法。
这是我的方法:
public bool IsEnableAccPosting(
string CompanyCode, DateTime FromDate, DateTime ToDate, out short Month)
{
try
{
o_dmDebitAccounts = new dmDebitAccounts(sysInfo);
bool IsEnable = false;
DataTable dt = o_dmDebitAccounts.GetDebitInterestAccPeriods(CompanyCode);
var query = from data in dt.AsEnumerable()
where data.Field<DateTime>("StartDate") == FromDate &&
data.Field<DateTime>("EndDate") == ToDate
select new
{
Month = Convert.ToInt16(data.Field<short>("Month")),
Year = Convert.ToInt16(data.Field<short>("Year"))
};
Month = (from item in query select (short)item.Month); //heres the error