+2  A: 
string CatName = a.CategoryTexts.
                 Single(ct => ct.LangID == (int)Session["LangID"]).CatName;

public string GetCatName(Area a)
{
    return a.CategoryTexts.
                 Single(ct => ct.LangID == (int)Session["LangID"]).CatName;
}
Leniel Macaferi
Fine but it's not in a function. If i'm in the view, I don't think it's the right way to perform this. How can i add your query in the CategoryText model.
Jean-Francois
Why do you think it's not the right way? You're using a lambda expression in the line above.
Leniel Macaferi
Ok, if I understand, I should add your GetCatName function in the partial class CategoryTexts.
Jean-Francois
That's it. But as I wrote I don't see much need for that. I think you could use the lambda expression directly.
Leniel Macaferi
I'M pretty sure there is a method with the Navigation Property to specify a 1 to 1 relation between the Category and CategoryText and customize the query for the user lang. Your query is ok, but if I need to make a loop throught all my Category, i'm not sure it's a good idea to execute this query for each of them.
Jean-Francois
No, there isn't because you need to check the LangID to get to your CatName. This way you must loop through your collection of CategoryTexts looking for a specific category that match that specific LangID.
Leniel Macaferi
Thanks Leniel, Great job, it's working perfecly.
Jean-Francois