c# - ASP .Net: Linq check if string array contains string subarray -
is there way check if 1 string array contains 1 string subarray? elements in array doesn't have identical elements in subarray, if it's not same strings can contain subarray's element part of string in bigger array.
for example:
- array["ax", "by", "cz", "dw", "eg"] contains subarray["a", "by", "e"]
- array["ax"] contains subarray["x"]
- array["ax", "by"] contains subarray["ax", "by"]
i need write in linq syntax, i'm getting subarray input "text" via form, , i'm splitting char(' '), on other hand i'm getting bigger array string split char(' ') database field.
what want do "search" on client, check if partially can filter database result.
i'm getting subarray client browser via input text field , that's ok, creating array each result got database:
var auctions = o in db.auctions select o;
i need pass auction.productname.split(' ') - array.
need filter auctions var checking if each productname.split(' ') contains string[] words subarray.
if asking check if: items of sub-array contained in "parent" array try this:
subarray.all(subitem => array.any(item => item.contains(subitem)));
Comments
Post a Comment