The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

momenee (2) [Avatar] Offline
#1
After moving up to .NET 4.0 the following LINQ query fails to compile:

var allergies = from allergy in typedDataSet.allergy
where allergy.drug != string.Empty
select allergy;

I had to change the query to the following, using the Cast<> extension method to explicitly cast the allergy variable to IEnumerable<> generic sequence.

var allergies = from allergy in typedDataSet.allergy.Rows.Cast<TypedDataSet.allergyRow>()
where allergy.drug != string.Empty
select allergy;

Would it make any difference if I rebuilt the typed dataset in 4.0? Or is it the 4.0 compiler that is finicky?
fabrice.marguerie (224) [Avatar] Offline
#2
Re: LINQ to DataSet change in .NET 4.0
I just created a new typed DataSet in .NET 4 and I can query it directly, without using Cast:

from row in new DataSet1().DataTable1
where row.DataColumn1 == "xyz"
select row.DataColumn2;

Could you try in a blank project with a new DataSet?
Also, what is the error message you are getting?