views:

14

answers:

0

Suppose I have few model classes like Person.cs, Car.cs, Manufacturer.cs each of which has 30-40 properties of varying datatypes. These models have to be populated using a Linq based framework called 'XrmContext' based on a Guid (primary key) match.

Ordinary way of doing this to populated each column one by one manually like

Person modelObject=new Person();
var xrm = new DataContext("MyXrmService");
var xrmPerson = xrm.CreateEntity("new_person");
xrmPerson.SetPropertyValue("new_ssn", modelObject.SSN);
xrmPerson.SetPropertyValue("new_personid", new Guid(modelObject.PersonGuid));

.... 20-30 statements like this which populate each property one by one.

Is there a better way of doing it where I can define mappings between Linq DataSource attributes and model properties.

Cheers!