Last post Dec 12, 2018 07:34 AM by Nan Yu
Dec 11, 2018 05:07 PM|geetasks|LINK
I was trying to get all records that satisfy filter condition something like below in linq:
Select * from trIncentives where isdeleted=false and SupplierId in (1,2,3,4) and status in"1,2"
In the below Linq, I am trying to add where condition:
strSupp=input.Supplier; //It can be null, can contain single value or multiple values sepated by comma.
var inc = _trIncentiveRepository.GetAll()
.WhereIf(!input.Filter.IsNullOrEmpty(),p => p.Name.Contains(input.Filter) )
How can this be achieved in the above LINQ?
Dec 12, 2018 07:34 AM|Nan Yu|LINK
Hi geetasks ,
You can try below code :
strSupp = input.Supplier; //It can be null, can contain single value or multiple values sepated by comma.
string filter = strSupp.Split(',');
var result = _trIncentiveRepository.GetAll().Where(p => filter.Contains(p.Name));
var result = _trIncentiveRepository.GetAll();