我想把它变成一个函数。我将传递 db 对象和 MVC 模型对象。这是原始代码:
var SomethingApproval = db.Somethings.AsQueryable();
var predicate = PredicateBuilder.True<Something>();
predicate = predicate.And(p => p.Approved == "N");
SomethingApproval = SomethingApproval.AsExpandable().Where(predicate);
我想要这样的功能
Function ApprovedItems (dbObject, modelObject)
{
var SomethingApproval = dbobject.AsQueryable();
var predicate = PredicateBuilder.True<modelObject>();
predicate = predicate.And(p => p.Approved == "N");
SomethingApproval = SomethingApproval.AsExpandable().Where(predicate);
return SomethingApproval
}