新增at lambda作为参数
本文关键字:参数 lambda at 新增 | 更新日期: 2023-09-27 18:15:40
我是新来的,有人能告诉我这是如何工作的,什么在"mycode"为了调用存储库?
public class MemberService : ServiceBase<IMemberModel>, IMemberService
{
public MemberViewModel GetSingle(Expression<Func<MemberViewModel, bool>> whereCondition)
{
mycode
}
}
public abstract class RepositoryBase<T> : IRepository<T>
{
public T GetSingle(Expression<Func<T, bool>> whereCondition)
{
return ObjectSet.Where(whereCondition).FirstOrDefault();
}
}
谢谢!
您需要的可能是基于Member的lambda,而不是MemberViewModel。你的方法应该像这样:
public MemberViewModel GetSingle( Expression<Func<Member,bool>> whereCondition )
{
var member = this.MemberRepository.GetSingle( whereCondition );
if (member != null)
{
return new MemberViewModel( member );
// or however you map from member to its view model
}
return null;
}