views:

15

answers:

0

Trying out a new project with Framework 4.0. I have 2 SQL Server tables with matching DBML entities in my project (EntA and EntB).

  • EntA has a Notes property that maps to a VarChar(50) column.
  • EntB has a NoteText property that maps to a Char(100) column.

I have some simple Linq-to-SQL code that prepends the text "* Note: " for each ent in EntA.

I now need to do this for EntB, but I would like to not repeat myself and use some strategy for doing the same thing I just did in EntA.

I was thinking I could make additional Partial Class code to give EntA and EntB a Property of some kind and then use Reflection on each entity for that Property and if it exists I find a "Notes" property and prepend. That does not feel elegant... As I add more tables/entities (eg EntC, EntD, etc) with potential "Notes" columns, I think there will be a lot of overhead adding what I need each time. I was also thinking of doing custom attributes on each property I care about but am afraid I would lose them when I regenerate the DBML.

Help?

Thanks.