Doubt in LINQ To BussinessListBase objectDoubt in LINQ To BussinessListBase object
Old forum URL: forums.lhotka.net/forums/t/8099.aspx
alagesan posted on Saturday, December 05, 2009
hi.,
iam using Linq against BussinessListBase objects,it have many records.
i wrote following Linq query but its shows error
BLJobCharge is BussinessListBase object
ChargeList is also BussinessListBase object
BLJobCharge ss = (from c in ChargeList
where c.JobAddressID == JobAddressID
select c).ToList();
but its show error as
Cannot implicitly convert type 'System.Collections.Generic.List<KlientInformatics.Roadways.Library.Sales.BTJobCharge>' to 'KlientInformatics.Roadways.Library.Sales.BLJobCharge' I:\KlientInformatics\KlientInformatics.Roadways.Library.Sales\JobAddress.cs 874 56 KlientInformatics.Roadways.Library.Sales
i want output as BussinessListbase object
how i want write the linq against Objects?
RockfordLhotka replied on Saturday, December 05, 2009
LINQ to Objects always returns an IEnumerable<T>, so you will not get back a BusinessListBase from a LINQ query.
LINQ to CSLA does change the way LINQ works, so what you will get back is a LinqBindingList<T>, which is more powerful than an IEnumerable<T>. You should read Chapter 14 to understand how this works.
JonnyBee replied on Sunday, December 06, 2009
Hi,
I would also suggest that you use the var declaration rather than declaring your type in advance.
Ie, your code should be:
var jobCharge = (from c in ChargeList
where c.JobAddressID == JobAddressID
select c).ToList();
Linq expressions may also return a new implicit anonymous type, a single value, a single <T>, IEnumerable<T> or LinqBindingList<T> when used against a BusinessListBase.
Copyright (c) Marimer LLC