Hi I want to write a model which will look like this:
public class Profile : Models.Users {
ModdDBEntities db = new ModdDBEntities();
public Profile( int user_id ) {
this = (Profile)(
from u in db.Users.Where(r => r.user_id == user_id )
select u
).First();
}
}
Is there any method to assign a values of every properties to this?
If you really want to copy all properties from one object to another, you can do this:
Where in your case,
obj1is the profile object, andobj2isthis.This only copies public properties, and of course, doesn’t check to ensure that obj2’s type declares all of the properties found in obj1’s type. Nor does it check that the same-named properties in both types are of the same type themselves. But it should get you started.
Not that I’d recommend doing this except in very unusual cases.