Как сравнивать строки в Linq Query

CompareTo у меня здесь не работает.

Мой запрос linq

var result = from c in customers 
             where c.CustomerID.CompareTo(txtSerchId.Text) >= 0 
             select` c;

и em получает исключение

//////EXCEPTION///////////

System.ArgumentException was caught
Message=Value does not fall within the expected range.

Мой код примерно такой

var result = 
    from c in customers 
    where c.CustomerID.CompareTo(txtSerchId.Text) >= 0 
    select c;

if (result != null)
{
    IEnumerator<Customer> resultEnum = result.GetEnumerator();
    while (resultEnum.MoveNext())
    {
        Customer c = (Customer)resultEnum.Current;
        addToDataSet(Guid.NewGuid().ToString(), c);
    }
    ShowResult();
}
else
{
    MessageBox.Show("No Customer found within criteria");
}

исключение в этой строке

IEnumerator<Customer> resultEnum = result.GetEnumerator();
6
задан rene 23 January 2016 в 19:33
поделиться