iam facing this issue in my function :
Expression of type 'System.Collections.Generic.IEnumerable1[sagoERP.PartiesDictionary.PartiesDictionaries]' cannot be used for parameter of type 'System.Linq.IQueryable
1[sagoERP.PartiesDictionary.PartiesDictionaries]' of method 'System.Linq.IQueryable1[sagoERP.PartiesDictionary.PartiesDictionaries] WhereIf[PartiesDictionaries](System.Linq.IQueryable
1[sagoERP.PartiesDictionary.PartiesDictionaries], Boolean, System.Linq.Expressions.Expression1[System.Func
2[sagoERP.PartiesDictionary.PartiesDictionaries,System.Boolean]])'
Function
public async Task<PagedResultDto<SalesInvoiceListingDto>> InvoicesList(FilterDto input)
{
try
{
var query = from inv in _txSalesInfo.GetAll().OrderByDescending(a => a.InvoiceDate)
.WhereIf(
!input.Filter.IsNullOrWhiteSpace(),
u =>
u.Invoicenumber.Contains(input.Filter) ||
u.CustomerName.Contains(input.Filter) ||
u.Refrencenumber.Contains(input.Filter)
)
from org in _organizationUnitRepository.GetAll().Where(a => a.Id == inv.SationId)
.WhereIf(
!input.Filter.IsNullOrWhiteSpace(),
u =>
u.DisplayName.Contains(input.Filter)
)
from op in _PartyRepo.GetAll().Where(a => a.Id == inv.OperatorId)
.WhereIf(
!input.Filter.IsNullOrWhiteSpace(),
u =>
u.JsonName.Contains(input.Filter)
)
select new SalesInvoiceListingDto
{
Id = inv.Id,
CustomerRefrenceNumber = inv.CustomerRefrenceNumber,
DueDate = inv.DueDate,
InvoiceDate = inv.InvoiceDate,
Invoicenumber = inv.Invoicenumber,
Refrencenumber = inv.Refrencenumber,
StatusId = inv.StatusId,
Operator = op.JsonName,
Station = org.DisplayName,
Customer = inv.CustomerName
};
var desiredItems = await query
.OrderByDescending(u => u.InvoiceDate)
.PageBy(input)
.ToListAsync();
var TotalCount = await query.CountAsync();
return new PagedResultDto<SalesInvoiceListingDto>(
TotalCount,
desiredItems
);
}
catch (Exception ex)
{
return null;
}
}
3 Answer(s)
-
0
Tip: Wrap your code in the following for formatting and readability:
[code]
[/code:11b8imqr] A shortcut is to highlight your code and click on the </> button in the formatting toolbar.
-
0
There is an IQueryable where if thats found here: Abp.Linq.Extensions
-
0
The expression expects
System.Collections.Generic.IEnumerable[sagoERP.PartiesDictionary.PartiesDictionaries]
as the first parameter, just like the exception states:
Expression of type 'System.Collections.Generic.IEnumerable
1[sagoERP.PartiesDictionary.PartiesDictionaries]' cannot be used for parameter of type 'System.Linq.IQueryable
1[sagoERP.PartiesDictionary.PartiesDictionaries]'I think the problem occurs when you sub filter parties... To test if this error occurs because of WhereIf you can replace all WhereIf statements with if statements.
from op in _PartyRepo.GetAll().Where(a => a.Id == inv.OperatorId) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.JsonName.Contains(input.Filter) )