Rakattack
asked on
how do i cast linc query result to ObservableCollection<>
i have the following ob collection defined :
public ObservableCollection<Servi ceBundleLo okup> ServiceBundles{
iwant to set it to the result of this link query :
ServiceBundles = (ObservableCollection<Serv iceBundleL ookup>)(fr om t in SBHs
where t.ServiceBundle != null
orderby t.ServiceBundle descending
select new { t.ServiceBundle }).Distinct();
But am getting trhe following error :
Unable to cast object of type '<DistinctIterator>d__81`1 [<>f__Anon ymousType0 `1[System. String]]' to type 'System.Collections.Object Model.Obse rvableColl ection`1[B nz.TTSC.Cl ient.Entit ies.Servic eBundleLoo kup]'.
public ObservableCollection<Servi
iwant to set it to the result of this link query :
ServiceBundles = (ObservableCollection<Serv
where t.ServiceBundle != null
orderby t.ServiceBundle descending
select new { t.ServiceBundle }).Distinct();
But am getting trhe following error :
Unable to cast object of type '<DistinctIterator>d__81`1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ServiceBundles = ( from t in SBHs
where t.ServiceBundle != null
orderby t.ServiceBundle descending
select new ServiceBundleLookup () { ServiceBundle = t.ServiceBundle }).Distinct().ToObservable Collection ();
where t.ServiceBundle != null
orderby t.ServiceBundle descending
select new ServiceBundleLookup () { ServiceBundle = t.ServiceBundle }).Distinct().ToObservable
ServiceBundles = new ObservableCollection<Servi
(
SBHs
.Where(t => t.ServiceBundle != null)
.OrderByDescending(t => t.ServiceBundle)
.Select(t => t.ServiceBundle)
.Distinct()
);
DaTribe