I have a LINQ object for which I need to create a special string value. These are 7 different values, separated by a "-". Some of the fields used are in this table, and some of them are in different tables. I would like to add this field to the object one way or another so that I do not have to create this line every time I need it.
I thought I could add it to an entity with a partial class like this:
public string SpecialField
{
get
{
return string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}",
TableId,
Number,
ForeignTableA.Date,
ForeignTableB.Name,
ForeignTableC.ForeignTableD.Name,
ForeignTableB.ForeignTableE.Name,
ForeignTableB.Number ?? 0);
}
}
However, after writing this, I got a little angry at how this would work. The reason, if I am mistaken, this will result in a database query every time this value is used for each item. And will this work, for example, to use this field in a Where clause?
Where, , , , .
?