Lazy initialization, ORMs, and lambdas
I was searching for a lightweight proxy so that we could lazy instantiate one or many objects in one hit.
rationale: perhaps the requests are batched up and sent to a server. i.e. that leads to n * latency if it is done individually. Additionally, if those batched requests could be served by one lambda or SQL statement, there's a potential for an additional time saving.
Scenario: say we have a database, a POCO model, a way of exposing that model (code generation/serialization), and a Silverlight client. The thought is, wouldn't it be neat if we could describe updates in terms of the POCO model instead of pushing these through CRUD style services? Like send an object graph instead.
Is this kind of thing covered in WCF? The only thing is, I'd rather not be using WCF. Also, something like nhibernate seems best in an ASP scenario.
My first thought was to do something like this, but so far that doesn't get me very far.
private Lazy<Person> _person = new Lazy<Person>(() => new Person());
publi开发者_JAVA技巧c Person person
{
get { return _person.Value; }
}
Maybe you should create a 'question' list on the client with lazy initialisation that executes the entire 'question' list once a single item has te be loaded. After this you can simply start a new list and load it once needed.
You could even add a little thread to empty the 'question' list on a background thread just to make sure you're using the network efficiently (based on priority or something).
精彩评论