LINQ XML query at c# wp7
        Posted  
        
            by 
                Karloss
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Karloss
        
        
        
        Published on 2011-11-20T08:49:20Z
        Indexed on 
            2011/11/20
            9:52 UTC
        
        
        Read the original article
        Hit count: 386
        
I am working at Windows Phone 7 C#, Xaml, XML and LINQ programming. I need to organize search by part of the name at following XML:
<Row>
  <Myday>23</Myday>
  <Mymonth>12</Mymonth>
  <Mynames>Alex, Joanna, Jim</Mynames>
</Row>
<Row>
  <Myday>24</Myday>
  <Mymonth>12</Mymonth>
  <Mynames>John, David</Mynames>
</Row>
I have following query:
var myData = from query in loadedData.Descendants("Row")
             where query.Element("Mynames").Value.Contains("Jo")
             select new Kalendars
                        {
                            Myday = (int)query.Element("Myday"),
                            Mymonth = (int)query.Element("Mymonth"),
                            Mynames = (string)query.Element("Mynames")
                        };
             listBoxSearch.ItemsSource = myData;
Query problem is, that it will return full part of the names like "Alex, Joanna, Jim" and "John, David". How can i get only Joanna and John? Second question is how it is possible to do that user enters ...Value.Contains("jo") and query still returns Joanna and John?
Possible solution (needs some corrections)
public string Search_names
        {
            get { return search_names; }
            set {
            string line = this.Mynames;
            string[] names = line.Split(new[] { ", " }, StringSplitOptions.None);
            var jos = from name in names
                      where name.Contains("is")
                      select name; // ["Joanna"]
            // HOW TO BIND search_names?
            }
        }
        © Stack Overflow or respective owner