LinQ nested search in Lists

VagelisVagelis GRMember ✭✭

Hi to All. I know that is not 100% Xamarin question, but I do not know if there is any limitation for Xamarin Forms and System.Linq.
I have a class like this:
<br /> public class SubMenu<br /> {<br /> public string Title { get; set; }<br /> public ObservableCollection<S1Strings> S1Strings { get; set; }<br /> }</p> <pre><code>public class MyStrings { public string Title { get; set; } public string Description { get; set; } }

I have a list of SubMenu(s) which are binding in a list view.
I want to search in my "MyStrings"
My code:
var a = SubMenus.Select(x => x.MyStrings.Select(y => y.Title.ToLower() == txt.ToLower())).ToList();
gives me exception "System.ArgumentNullException: Value cannot be null.
Parameter name: source".

Any help?
Thanks in advance

Posts

  • JoeMankeJoeManke USMember ✭✭✭✭✭
    edited February 12

    That's not really a LINQ issue, that just means one of your ObservableCollections is not getting initialized. Either the SubMenus list or the MyStrings list in a SubMenu has not been set to a new ObservableCollection.

Sign In or Register to comment.