【发布时间】:2013-03-06 20:45:28
【问题描述】:
在这行代码中我有这个错误不能隐式地将 Enumerable 行集合<short> 转换为short:
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
【问题讨论】: