Entity Framework Code First - Reducing round trips with .Load() and .Local?

It is completely ok to make several DB calls if you need them. If you are affraid of multiple roundtrips you can either write stored procedure and return multiple result sets (doesn't work with default EF features) or execute your queries asynchronously (run multiple disjunct queries in the same time). Loading unrealted data with single linq query is not possible Just one more notice.

If you decide to use asynchronous approach make sure that you use separate context instance in each asynchronous execution. Asynchronous execution uses separate thread and context is not thread safe.

It is completely ok to make several DB calls if you need them. If you are affraid of multiple roundtrips you can either write stored procedure and return multiple result sets (doesn't work with default EF features) or execute your queries asynchronously (run multiple disjunct queries in the same time). Loading unrealted data with single linq query is not possible.

Just one more notice. If you decide to use asynchronous approach make sure that you use separate context instance in each asynchronous execution. Asynchronous execution uses separate thread and context is not thread safe.

I think you are doing a lot of work for little gain if you don't already have a performance problem. Yes, pay attention to what you are doing and don't make unnecessary calls. The actual connection and across the wire overhead for each query is usually really low so don't worry about it.

Remember "Premature optimization is the root of all evil".

True that. I'm in pre production now and want to get a handle on how these systems will be architected, seems like caching is the way to go for db call optimization. – BrooklynDev Mar 30 at 21:11 "... in say 97% of the time." – AviD Oct 10 at 13:50.

My rule of thumb is that executing a call for each collection of objects you want to retrieve is ok. Executing a call for each row you want to retrieve is bad. If your web page requires 20 collections then 20 calls is ok.

That being said, reducing this to one call would not be difficult if you use the Translate method. Code something like this would work var reader = GetADataReader(sql); var firstCollection = context. Translate(reader); reader.NextResult(); var secondCollection = context.

Translate(reader); etc The big down side to doing this is that if you place your sql into a stored proc then your stored procs become very specific to your web pages instead of being more general purpose. This isn't the end of the world as long as you have good access to your database. Otherwise you could just define your sql in code.

It is completely ok to make several DB calls if you need them. If you are affraid of multiple roundtrips you can either write stored procedure and return multiple result sets (doesn't work with default EF features) or execute your queries asynchronously (run multiple disjunct queries in the same time). Loading unrealted data with single linq query is not possible.

I think you are doing a lot of work for little gain if you don't already have a performance problem. Yes, pay attention to what you are doing and don't make unnecessary calls. The actual connection and across the wire overhead for each query is usually really low so don't worry about it.

Walt will be greatly missed. He was a nice, approachable guy who made PCI a lot less scary in higher education. Very sad to hear about Walt's passing.

I had a chance to attend a couple of his talks and he still is the only one who could get people engaged and interested in PCI issues and make them less daunting without losing the seriousness of the subject matter. His columns on this sites were always very helpful and were frequently used by me to help explain this complex subject matter. 403Labs, Walt's employer for years, has just posted a very nice tribute: http://www.403labs.com/walt.

Walt's wit and wisdom will be missed by all. My deepest sympathies to his family & friends. I never met Walt, but used his articles in presentations to clients frequently.

Always a resources for accurate explanations that were easy to understand. I will always remember Walt's refreshing approach to PCI compliance when he worked with me at two institutions. Other consultants generally said, ok we saw what you have, here is the checklist to comply with SAQ D.

Walt would turn it all around and say, for a campus your size you should be able to get your scope down to this, and by the way, here is what worked with your 3rd party on another campus I worked with... I will miss his wit and his gentle soul. I was fortunate to meet Walt at a time when my campus was beginning the marathon known as PCI compliance. His knowledge was immense and his advice very simple.

By the time he completed an engagement with our school, we had become friends. We enjoyed many conversations about things not related to work and shared a meal or two at professional meetings and symposiums. My deepest condolences to his sweet wife Meredith, his family, colleagues, and many friends.

While I never met Walt Conway, his articles were very informative and he definitely left an impression with his knowledge. What is it with PCI columnists at StoreFront BackTalk? Before Walt, we lost the amazing David Taylor in 2009, who enlightened so many with his crisp writing and insightful viewpoints.

I just cannot believe it. Walt and I had known one another for a number of years and I finally met him in person at the first PCI Community Meeting in Toronto. He and I bantered back and forth for years over the infamous session at that Meeting held by the card brands where they discussed whether pre-authorization data was in-scope.

For the record, it was NOT in-scope, but was to be protected as though it were in-scope. I will miss him dearly as he was always will to tell me when I was getting things wrong. RIP my friend.

That is incredibly sad news indeed. Walt was extremely knowledgeable about information security (and PCI DSS in particular), but he also made the subject approachable to many (a very rare gift in the industry). He will be missed!

This is truly sad news. Walt helped educate us here at Intel about PCI and was a tremendous resource for us. He will be missed.

I've been absent from the world and just found out about this very sad news. In the few conversations I had with him I had very similar experiences: personable, intellegent and very nice. Walt will be greatly missed.

This is really sad news, I had met Walt when I started PCI work and has been a great resource to me and our Company. He will be really missed. While I've been very behind on my reading, I am so sad to hear of this news.

I absolutely loved Walt's style of writing, and of course the content was top notch. I appreciated that he even took a call or two to discuss a few PCI topics - and he had a great sense of humor as well. Walt - you will be missed!

In 1990 I worked closely with Walt in Visa EMEA/London office : he was our diplomatic pioneer to open doors with rather suspicious "rivals" like American Express, Diners Club, and MasterCard when we were building electronic transaction processing bridges to their hubs. None of them could resist his charm offensive! Now I realise that he had continued to use his ideal mix of personal charm and technical prowess to win hearts and minds in the PCI DSS world too.

And it's very humbling to know that he was so involved with helping the homeless. Salute to you, Walt!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions