public DiaryCommentService(int commentId, IDiCommentRepository DiCommentRepository) { ExceptionHelper.ThrowIfNotId(commentId, "messageCommentId"); _commentId = commentId; _DiCommentRepository = DiCommentRepository; //懒加载的Diary获取 _LazyDiaryComment = new Lazy <Data.DiaryComment>(() => { var diarycomment = DiCommentRepository.EnableDiaryComment.Where(m => m.CommentId == commentId).FirstOrDefault(); if (diarycomment == null) { throw new ExceptionWithErrorCode(ErrorCode.没有找到对应条目, "日志评论不存在"); } return(diarycomment); }); }
public DiaryService(int diaryId, IDiaryRepository diarepository, IDiCommentRepository dicommentRepository) { ExceptionHelper.ThrowIfNotId(diaryId, "diaryId");//用来报错的; _diaryId = diaryId; _dicommentRepository = dicommentRepository; _diarepository = diarepository; //懒加载的Diary获取 //设置懒加载,设置Diary类diary对象的搜索 //我们创建某一个对象需要很大的消耗,而这个对象在运行过程中又不一定用到, //为了避免每次运行都创建该对象,这时候延迟初始化(也叫延迟实例化)就出场了。 _LazyDiary = new Lazy <Data.Diary>(() => { var diary = _diarepository.EnableDiary.Where(m => m.DiaryId == _diaryId && m.IsDel != true).FirstOrDefault(); if (diary == null) { throw new ExceptionWithErrorCode(ErrorCode.没有找到对应条目, "日志不存在"); } return(diary); }); }
public DiaryManager(IDiaryRepository diaryRepository, IDiCommentRepository dicommentRepository, IUserManager userManager) { _diarepository = diaryRepository; _dicommentrepository = dicommentRepository; _userManager = userManager; }
public DiaryCommentManager(IDiCommentRepository dicommentrepository) { _DiCommentRepository = dicommentrepository; }