LINQ其中有四个与放大器条款;&安培; [英] LINQ Where clause with four &&
本文介绍了LINQ其中有四个与放大器条款;&安培;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在WHERE子句中有4个参数来创建一个LINQ查询。这是一个Windows 8应用项目,我使用的是SQLite数据库。 ( SQLite的实施)
I'm trying to create an LINQ Query with 4 arguments in the Where clause. It's a Windows 8 App project and I'm using an SQLite Database. (SQLite implementation )
这里的代码片段:
public List<FinancialListBoxExpenseItem> retrieveExpenseItems(int month, int year, bool isPaid, StaticResources.FrequencyEnum frequencyEnum)
{
List<FinancialListBoxExpenseItem> tmpList = null;
connection.RunInTransaction(() =>
{
var items = from s in connection.Table<FinancialListBoxExpenseItem>()
where (s.expenseDateNextPayment.Month == month)
&& (s.expenseDateNextPayment.Year == year)
&& (s.expensePaidForCurrentPeriod == isPaid)
&& (s.expenseFrequencyTypeEnum == frequencyEnum)
select s;
tmpList = items.ToList<FinancialListBoxExpenseItem>();
});
return tmpList;
}
它抛出一个NotSupportedAction:成员访问失败编译表达异常
It throws a NotSupportedAction: Member access failed to compile expression Exception
我不知道这是什么意思,我应该如何解决这个问题。
I have no idea what does this mean and how i'm supposed to fix it.
编辑:它作品,未经where子句因此,错误也必须在代码
it works without the where clause therefore the error must be related to this where clause part of the code
推荐答案
这是与此有关我怎么解决这个问题:
This is how i solved the problem:
public List<FinancialListBoxExpenseItem> retrieveExpenseItems(int month, int year, bool isPaid, StaticResources.FrequencyEnum frequencyEnum)
{
List<FinancialListBoxExpenseItem> tmpList = new List<FinancialListBoxExpenseItem>();
connection.RunInTransaction(() =>
{
var items = from s in connection.Table<FinancialListBoxExpenseItem>()
let convertedDate = (DateTime)s.expenseDateNextPayment
where (convertedDate.Month == month)
&& (convertedDate.Year == year)
&& (s.expensePaidForCurrentPeriod == isPaid)
&& (s.expenseFrequencyTypeEnum == frequencyEnum)
select s;
tmpList = items.ToList();
});
return tmpList;
}
这篇关于LINQ其中有四个与放大器条款;&安培;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文