Using LINQ on an ObservableCollection<t></t>
-
Hello Guys, I already asked this question under WPF forum, but since a portion of my code is LINQ, well here you go. I have a class <code>Client</code> of which I use to return a collection of clients from the database as an ObservableCollection:
ObservableCollection<Client> myClients = queries.GetClients();
where
GetClients()
is a method that returns a list of clients of typeObservableCollection<Client>
Now I use LINQ to run a search for clients as follows:ObservableCollection<Client> filteredClients = null; IEnumerable<Client> qry = from c in myClients where c.Name.ToUpper().Contains(txtSearch.Text.ToUpper()) orderby c.Name select c; filteredClients = new ObservableCollection<Client>(qry);
Hence
filteredClients
is supposed to contain a subset of myClients of the same typeObservableCollection<Client>
My problem is that this works fine on my x64 vista/machine, but when I move it to my x86 vista/machine I get an error that:Argument '1': cannot convert from 'System.Collections.Generic.IEnumerable<Client>' to 'System.Collections.Generic.List<Client>'
After poking around a bit, I discovered that in my Visual Studio (both machines run VS.NET 2008 on Framework 3.5) on the x64 machine, the
ObservableCollection<T>
class has 3 overloads and one of them accepts anIEnumerable<T>```` , which is exactly what `qry` above is. However, on my x86 as you can guess, there are only 2 constructors and ``` IEnumerable<T>``; isn't one of the parameters. Just an empty overload and one that receives a `List<T>` So then my question is why is there this disparity in the number of overloads on vista x64 platform and vista x86? Does this mean that I would have to design an auxiliary class that'll return a List<T> from my backend rather than `an ObservableCollection<T>` for x86 platforms? P.S: That is just one of the compatibility problems I believe those of us building applications with WPF are facing. Another one I hit is that if I have a ListBox with a DataTemplate and I set its SelectedValuePath, it works fine on my x64 machine but appears null on my x86 machine. My 2 pennies for other deve`` ``` ````
-
Hello Guys, I already asked this question under WPF forum, but since a portion of my code is LINQ, well here you go. I have a class <code>Client</code> of which I use to return a collection of clients from the database as an ObservableCollection:
ObservableCollection<Client> myClients = queries.GetClients();
where
GetClients()
is a method that returns a list of clients of typeObservableCollection<Client>
Now I use LINQ to run a search for clients as follows:ObservableCollection<Client> filteredClients = null; IEnumerable<Client> qry = from c in myClients where c.Name.ToUpper().Contains(txtSearch.Text.ToUpper()) orderby c.Name select c; filteredClients = new ObservableCollection<Client>(qry);
Hence
filteredClients
is supposed to contain a subset of myClients of the same typeObservableCollection<Client>
My problem is that this works fine on my x64 vista/machine, but when I move it to my x86 vista/machine I get an error that:Argument '1': cannot convert from 'System.Collections.Generic.IEnumerable<Client>' to 'System.Collections.Generic.List<Client>'
After poking around a bit, I discovered that in my Visual Studio (both machines run VS.NET 2008 on Framework 3.5) on the x64 machine, the
ObservableCollection<T>
class has 3 overloads and one of them accepts anIEnumerable<T>```` , which is exactly what `qry` above is. However, on my x86 as you can guess, there are only 2 constructors and ``` IEnumerable<T>``; isn't one of the parameters. Just an empty overload and one that receives a `List<T>` So then my question is why is there this disparity in the number of overloads on vista x64 platform and vista x86? Does this mean that I would have to design an auxiliary class that'll return a List<T> from my backend rather than `an ObservableCollection<T>` for x86 platforms? P.S: That is just one of the compatibility problems I believe those of us building applications with WPF are facing. Another one I hit is that if I have a ListBox with a DataTemplate and I set its SelectedValuePath, it works fine on my x64 machine but appears null on my x86 machine. My 2 pennies for other deve`` ``` ````