Monday, February 21, 2011

Linq To Sql Intellisense Property Names

If I had two tables such as this:

Profile Table 
-------------
PK ProfileID int
FK AddressPrimaryID int
FK AddressSecondaryID int

Address Table
-------------
PK AddressID int
Address nvarchar
City nvarchar
State nvarchar
Zip nvarchar

Notice, the profile has a two relationships to the same table, the address table. When I create my linq to sql class in VS2k8, I add my tables to the dbml. Then I am referencing this profile table in a service and I perform a query to return the first record from the profile repository. No problems there...

I get my single record and I now have intellisense on the object (profile object). I have all my properties plus the Address(object) and Address1(object). Now the Address and Address1 are the actual objects from the relationship built by linq to sql, what I want to know is can I control what the name is for this object in intellisense, so instead of Address and Address1 I could have AddressPrimary and AddressSecondary for the object name in intellisense. It would just make things clearer. Any ideas?

From stackoverflow
    1. Right Click the association on the DBML design surface and click properties.
    2. Expand "Child Property".
    3. Set the "Name" property to whatever you'd like.

0 comments:

Post a Comment