Reputation: 3379
say I've a entity class user
. Now in that class, I want to do:
partial class user{
public void save()
{
using (ent e = new ent())
{
var res = (from u in e.user where u.name == name select u).first();
res = someOtherUserObject;
context.SaveChanges();
}
}
}
The question may have been already answered but I could not find the link.
Upvotes: 0
Views: 641
Reputation:
Q2: Is it possible to retrive a entity and marking as if it is changed without actually changing it?
See this:
using (var context = new BloggingContext())
{
var blog = context.Blogs.Find(1);
context.Entry(blog).Property(u => u.Name).IsModified = true;
// Use a string for the property name
context.Entry(blog).Property("Name").IsModified = true;
}
Upvotes: 1