How to explicitly specify which objects to load from DB?
Posted: Fri 27 Mar 2009 10:30
Hello
I am desperate. I have a Countries table and a related CountryTranslations table with the translations of each country name. Now I'd like to fetch all countries from the Countries table but fetch only the English translations in the related CountryTranslations table. In Microsoft LINQ this is possible with the LoadWith And AssociateWith DataLoadOptions. What's the workaround in Devart?
I was trying something like this:
But because of deferred loading, each Country object will have all it's related translations in the CountryTranslation property.
How is it possible to only fill the releated data due to a condition (for example with a lambda expression)?
I don't want to reload each country's translation with a separate sql query as done with the automatic deferred loading. I want to fetch the data all at once within a single query (joined) like above.
Please help! Thank you very much
Thomas
________
Weed
I am desperate. I have a Countries table and a related CountryTranslations table with the translations of each country name. Now I'd like to fetch all countries from the Countries table but fetch only the English translations in the related CountryTranslations table. In Microsoft LINQ this is possible with the LoadWith And AssociateWith DataLoadOptions. What's the workaround in Devart?
I was trying something like this:
Code: Select all
var recordSet = from c in PPGlobal.Countries
join ct in PPGlobal.CountryTranslations on c.CountryId equals ct.CountryId
join l in PPGlobal.Languages on ct.LanguageId equals l.LanguageId
where l.Abbreviation.ToLower() == "en"
select new { CountryTranslation = ct, Country = c };
List countries = new List();
foreach (var record in recordSet)
{
record.Country.CountryTranslations.Add(record.CountryTranslation);
countries.Add(record.Country);
}
How is it possible to only fill the releated data due to a condition (for example with a lambda expression)?
I don't want to reload each country's translation with a separate sql query as done with the automatic deferred loading. I want to fetch the data all at once within a single query (joined) like above.
Please help! Thank you very much
Thomas
________
Weed