arch/UnitOfWork

I need to include an entity but with a condition

itcozum opened this issue · 5 comments

Hi,

I need some help running this; I need to include the second table with a condition like so;

DateTime _mydate = BusinessDaysUtility.ConvertFromDateTimeOffset(model.Today.Value.Date);

            var results = await _unitOfWork.GetRepository<PersonnelTable>().GetPagedListAsync(

            disableTracking: true,
            predicate: t => t.CompanyBranchId.Equals(model.CompanyBranchId) && t.Status == true,
            pageIndex: model.PageIndex, pageSize: model.PageSize,
            **include: source => source.Include(w => w.EmployeeCheckInCheckoutData.Where(c => c.CheckInDate.HasValue && c.CheckInDate.Value.LocalDateTime.Date.Equals(_mydate.Date) && c.IsDeleted != true)**
           ));

But I'm getting this error message:-

The Include property lambda expression 'w => {from EmployeeCheckInCheckoutData c in w.EmployeeCheckInCheckoutData where ((([c].CheckInDate != null) AndAlso Convert([c].CheckInDate, DateTimeOffset).LocalDateTime.Date.Equals(___mydate_Date_0)) AndAlso ([c].IsDeleted != True)) select [c]}' is invalid. The expression should represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, specify an explicitly typed lambda parameter of the target type, E.g. '(Derived d) => d.MyProperty'.

please reply, this is the second time I'm asking for this help.

thanks in advance.

The prompt message had tell you how to do it

can u pls just help ??

this is very unfortunate that you've just DIS me for no reason, at list what ask of you is doable.

please I need your help about this subject.. adding where clause to include..

@xyting can I get an example of how you got this to work properly