I have used Entity Framework and it generated some entity classes for me I want to add a property to one of them there are a lot fields and attribute inside it, when I am going to add property to entity class I have to make child class which is inherited from my entity class then I am usually write this and it works :
IList<newEntity> chid = (from m in db.Entity
select new newEntity
{
//rewrite all properties here
newAttribute = ConvertDate(n.date) //it is example I break it into steps and called some functions to fill new attribute
}).ToList();
My question is how I can avoid rewriting all attribute here it really make me bored to write some code I can just add a new property how I can do that?
I’m not sure if I understood your question correctly, but usually the classes generated by the Entity Framework are partial classes(*), so you don’t need to derive from them to add a property. You can add properties, methods etc by adding a class to your codebase with the same name and in the same namespace and then the two definitions are merged by the compiler:
(*) depending on your code generator