Reputation: 10624
In mysql,
select distinct(trim(containerType)) from productIn where containerType <> '' group by containerNo
How can I make expression that query using Lambda?
Ex)
List<string> containerTypes = new List<string>();
containerTypes = productInRepository.GroupBy(x=> x.containerNo).Select(?????).ToList();
Upvotes: 2
Views: 172
Reputation: 6741
I think groupby field which is not in result select means the same as orderby this field.
List<string> containerTypes = productInRepository
.Where(x => x.containerType != string.Empty)
.OrderBy(x => x.containerNo)
.Select(x => x.containerType.Trim())
.Distinct();
Upvotes: 1
Reputation: 35107
List<string> containerTypes = productInRepository
.Where(x => x.containerType != string.Empty)
.GroupBy(x=> x.containerNo)
.Select(x => x.containerType.Trim())
.ToList();
Upvotes: 1