I’ve this simple Entities from DB tables

But i want my POCO classes to be just two classes:
public class Country
{
public string ID { get; set; }
public string Name { get; set; }
public string LocalName { get; set; } // this localized
public string Region { get; set; }
public IEnumerable<City> Cities { get; set; }
}
public class City
{
public int ID { get; set; }
public string CountryID { get; set; }
public string Name { get; set; } //this localized
public double? Longitude { get; set; }
public double? Latitude { get; set; }
}
Then i want Localized properties “LocalName for the Country and Name for the City” to be filled by my context.
So how to map this Entities to POCO Classes?
And is there better way to do that?
Or i should make manual converting from Entities to my Model and add one more tier ?
Please help me to take decision .
.
: Additional information:
I made my ObjectContext to deal with my POCO but when i try to fill my Additional property “LocalName” in repository i get this error:
The entity or complex type 'Site.Country' cannot be constructedin a LINQ to Entities query.
and this is the method in my Repository:
public IQueryable<Country> GetCountries()
{
return from country in context.Countries
join countryCul in context.CountriesCultures
on country.Code equals countryCul.CountryID
where countryCul.LangID == "en"
select new Country
{
Code = country.Code,
LocalName = countryCul.LocalName,
Name = country.Name,
Region = country.Region,
};
}
I don’t know how to fill “LocalName” property within linq statement
if you want a solution with ViewModel class, you can pick up these:
For wrapping City with it’s selected LocalLanguage
Here, we chose the either default so with if else no join, else chose from CityCulture table
and this one for passing View:
finally at view:
i think this is it.
moguzalp