C# 条件λ
我想应用一个条件,在我通过另一个条件后,如下所示:C# 条件λ,c#,lambda,conditional,conditional-statements,C#,Lambda,Conditional,Conditional Statements,我想应用一个条件,在我通过另一个条件后,如下所示: List<Entity> GetByCondition() { If(dateConditionEnabled) { Repository.Get(i=>i.start<=datetime.Now && i.EndDate<=DateTime.Now); } else { Repository.Get(); } } List
List<Entity> GetByCondition()
{
If(dateConditionEnabled)
{
Repository.Get(i=>i.start<=datetime.Now && i.EndDate<=DateTime.Now);
}
else
{
Repository.Get();
}
}
List GetByCondition()
{
如果(已启用日期条件)
{
Repository.Get(i=>i.start是Get()
等同于Get(i=>true)
?在这种情况下,您可以使用:
List<Entity> GetByCondition()
{
return Repository.Get(!dateConditionEnabled || i=>i.start<=datetime.Now && i.EndDate<=DateTime.Now);
}
List GetByCondition()
{
return Repository.Get(!dateConditionEnabled | i=>i.start是Get()
相当于Get(i=>true)
?在这种情况下,您可以使用:
List<Entity> GetByCondition()
{
return Repository.Get(!dateConditionEnabled || i=>i.start<=datetime.Now && i.EndDate<=DateTime.Now);
}
List GetByCondition()
{
return Repository.Get(!dateConditionEnabled | | i=>i.start为什么不呢
List<Entity> GetByCondition()
{
return Repository.Get(i=>!i.dateConditionEnabled || i.start<=datetime.Now && i.EndDate<=DateTime.Now);
}
List GetByCondition()
{
return Repository.Get(i=>!i.dateConditionEnabled | | i.start为什么不呢
List<Entity> GetByCondition()
{
return Repository.Get(i=>!i.dateConditionEnabled || i.start<=datetime.Now && i.EndDate<=DateTime.Now);
}
List GetByCondition()
{
return Repository.Get(i=>!i.dateConditionEnabled | | i.Start谢谢你哈姆雷特,亨里克首先回答。但是你文章的第一部分,!i.dateConditionEnabled是正确的。“dateConditionEnabled”是存储库条目的成员还是包含GetByCondition()的类的一部分?如果是类的一部分,则i=>!i.dateConditionEnabled将给出错误。dateConditionEnabled是我的实体的属性,但否,此处没有错误:)谢谢你,哈姆雷特,亨里克首先回答。但是你文章的第一部分,!i.dateConditionEnabled是正确的。“dateConditionEnabled”是存储库条目的成员还是包含GetByCondition()的类的一部分?如果是类的一部分,则i=>!i.dateConditionEnabled将给出错误。dateConditionEnabled是我的实体的属性,但否,此处没有错误:)