【发布时间】:2012-07-01 17:05:59
【问题描述】:
我的框架中有 DTOmodel。 BLL 和 View 根本看不到 EntiyModel。我想在图层之间传输和转换复杂表达式。
这是BLL中的一个方法……
//// BLL(Service)
Public PersonDTO getAll(Expression<Func<PersonDTO, bool>> whereCondition)
{
return _repository.getAll(whereCondition);
}
// DLL(Repository)
Public PersonDTO getAll(Expression<Func<PersonDTO, bool>> whereCondition)
{
Expression<Func<Person, bool>> NewCondition = ?/ How Convert DTOwhereCondition ???
return DataContext.Persons(NewCondition);
}
///// 我想像这样在 PersonDTO 上创建复杂的表达式:
var persons = serive.getPersons(i => i.PersonDetailsDTO.Count == 3);
///// 我的课程
public class Person
{
public Int32 Id { get; set; }
public String FirstName { get; set; }
public String LastName { get; set; }
public List<PersonDetail> PersonDetails { get; set; }
}
public class PersonDTO
{
public Int32 Id { get; set; }
public String FirstName { get; set; }
public String LastName { get; set; }
public List<PersonDetailDTO> PersonDetailsDTO { get; set; }
}
【问题讨论】:
-
不太清楚您要做什么。您可能想提供更多信息。如果你有表达式作为参数,你可以传递一个 lambda 表达式。
标签: c# architecture expression n-tier-architecture