我找到了这个通用存储库,但我确实找到了一种使用它的方法:
public T FindSingle(Expression<Func<T, bool>> predicate = null, params Expression<Func<T, object>>[] includes)
{
var set = FindIncluding(includes);
return (predicate == null) ? set.FirstOrDefault() : set.FirstOrDefault(predicate);
}
我怎么能称之为包括这样的几个相关实体?:
Message messageParentDomain = _messageRepository.FindSingle(m => m.Id == messageDto.MessageParent_Id, includes: i => i.MemberFrom, i => i.MemberTo);
留言类:
public class Message
{
// Primary properties
public int Id { get; set; }
public string NameFrom { get; set; }
public string EmailFrom { get; set; }
public string TelephoneFrom { get; set; }
public string Title { get; set; }
public string MessageText { get; set; }
public bool? Approved { get; set; }
public DateTime DateCreated { get; set; }
public DateTime? DateRead { get; set; }
// Navigation properties
public Member MemberFrom { get; set; }
public Member MemberTo { get; set; }
public MessageType MessageType { get; set; }
public Message MessageParent { get; set; }
public Ad Ad { get; set; }
public Ask Ask { get; set; }
}
谢谢。