我的框架中有DTOmodel。 BLL和View根本沒有看到EntiyModel。我想在圖層之間傳輸和轉換複雜表達式。將複雜表達式<Func<TDTO>,bool>轉換爲表達式<bool>
這是在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表達式。 –