I'm using VS2010, EF. My goal is to combine multiple columns in my metadata so I can display a complete address in one column from a gridview (list).
Such as:
The Coffee House
100 Main Street
South Bend, IN 46556
Here's my code; (I also want to add line breaks)
[MetadataType(typeof(ResHistoryMetaData))]
public partial class ResHistory
{
}
public class ResHistoryMetaData
{
[DisplayColumn("Address1", "Address1", false)]
public partial class Address1
{
public override string ToString()
{
return Address1.ToString() + " " + Address2.ToString() + " " + City.ToString() + " " + State.ToString() + " " + Zip.ToString();
}
}
}
The error I'm getting:
Error 2 The name 'Address2' does not exist in the current context
Error 3 The name 'City' does not exist in the current context
Error 4 The name 'State' does not exist in the current context
Error 5 The name 'Zip' does not exist in the current context
Member
17 Points
90 Posts
Combine multiple columns in EF
Sep 29, 2010 11:32 AM|jjfrick|LINK
Hello,
I'm using VS2010, EF. My goal is to combine multiple columns in my metadata so I can display a complete address in one column from a gridview (list).
Such as:
The Coffee House
100 Main Street
South Bend, IN 46556
Here's my code; (I also want to add line breaks)
The error I'm getting:
Error 2 The name 'Address2' does not exist in the current context
Error 3 The name 'City' does not exist in the current context
Error 4 The name 'State' does not exist in the current context
Error 5 The name 'Zip' does not exist in the current context
Combine multiple columns in EF
All-Star
17915 Points
5679 Posts
MVP
Re: Combine multiple columns in EF
Sep 29, 2010 12:54 PM|sjnaughton|LINK
Simple solution your ToString method is in the wrong place
The ToString method must be in the Partial class of the actual entity not the buddy class, you only add metadata to the buddy class.
Dynamic Data
Always seeking an elegant solution.