Click here to Skip to main content
15,119,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So here is my situation:

I need to map a property to a concatenation of two fields, and I'm not exactly sure how it should be done.

Here's a code sample of what IN THEROY I am trying to accomplish:

Property AccountSequence = table.PART1 + table.PART2
where Part1 and Part2 are varchar

public class MyObjectConfiguration : EntityTypeConfiguration<TemporaryObject>
    public MyObjectConfiguration()

        Property(p =>p.AccountSequence).HasColumnName("PART1").HasColumnName("PART2");

1 solution

I would add a partial class to extend my EF class, to create a new property that concatenates the two you're talking about. You could then define any business rule you want if you want to also accept a setting of one value, and split it to store two.
Tom Wauters 12-Jun-13 0:00am
You can also override the ToString() method in that partial class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900