【发布时间】:2023-03-07 01:51:01
【问题描述】:
如果我想运行这样的东西
BLL.Person person = (BLL.Person)repository.Single(item => item.Id == Id);
在我的单一方法中,我会做这样的事情:
public Resource Single(Expression<Func<BLL.Resource, bool>> where)
{
Resource resource = AsQueryable().FirstOrDefault(where);
return resource;
}
protected IQueryable<BLL.Resource> AsQueryable()
{
// I need to use the where clause on an object called DAL.Resource
throw new NotImplementedException();
}
DAL.Resource 对象与 BLL.Resource 相同,但是 BLL 副本不知道持久性。我可以使用 automapper 映射事物以返回我想要的集合,但是我需要 where 子句运行对抗 DAL 而不是 BLL...
这一定是可能的!任何想法将不胜感激。
【问题讨论】:
标签: c# .net linq reflection iqueryable