I’m extending an entities’ partial class to have a method. How do I get a reference to the context that the entity is attached to (if any) to get more entities from the same context.
If that’s not clear, basically the code I’m looking to write is along these lines (air code):
public void AssignSize(int width, int height) { var size = (from s in this.context.Sizes where s.width == width && s.height == height select s).FirstOrDefault(); ... }
Nb: This doesn’t work.
You need to pass the context to this method, or, better yet, rather than pass in width and height, pass in the size object itself.