EF4 : Complex Type

EF4 : Complex Type

  • Comments 0

Is to simplify your life which might seem too complex :). Let’s suppose you have a table like,

image

Now you might want to club all address related field and make one single representation to it. Once you have created the model in your Visual Studio 2010, you may just need to select all the properties and choose the option to create the Complex Type.

image

Once you have done it, the Model Browser and Model would look like,

image

Your query to fetch the required data then would look like,

using (var ctx = new TestDBEntities())
{
    var q = from c in ctx.Addresses
            select c;

    foreach (var k in q)
    {
        Console.WriteLine(k.AddLines.Street);
        Console.WriteLine(k.AddLines.Country);
    }
}

Namoskar!!!

Leave a Comment
  • Please add 4 and 3 and type the answer here:
  • Post