gpt4 book ai didi

c# - 组合 Where 语句的表达式

转载 作者:行者123 更新时间:2023-12-03 19:15:14 27 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How do I combine LINQ expressions into one?

public bool IsUnique(params Expression<Func<Employee, bool>>[] properties)
{
var combinedProperties = Combine(properties);
var rowCount = _session.QueryOver<Employee>().Where(combinedProperties).ToRowCountQuery().RowCount();
return rowCount == 0;
}

Expression<Func<Employee, bool>> Combine(Expression<Func<Employee, bool>>[] properties)
{
???
}

用法:

var isUnique = _employeeRepository.IsUnique(x => x.FirstName == commandMessage.FirstName, x => x.LastName == commandMessage.LastName);

有没有一种方法可以将谓词与 AND 运算符结合起来?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com