C
C#3y ago
Dreams

Linq to select where Name contains substring?

var dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Any(i => i.Name.Contains(substring))
.ToListAsync();
var dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Any(i => i.Name.Contains(substring))
.ToListAsync();
I want to return all rows where the Name field contains a substring
5 Replies
Saber
Saber3y ago
ok lets think about this logically, why would you be using Any instead of Where which you explicitly say in the description of what you want
TheBoxyBear
TheBoxyBear3y ago
^
Dreams
DreamsOP3y ago
i'm helpless with Linq
TheBoxyBear
TheBoxyBear3y ago
Any as the name implies just returns a bool, true if any of the items meet the condition
Dreams
DreamsOP3y ago
ah ok thank you wow it worked!

Did you find this page helpful?