Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Considering that I use code like (with or without using (considering that using(??) may dispose context)):

IQueryable<Konsultanci> listaKonsultantow;
using (var context = new EntityBazaCRM(Settings.sqlDataConnectionDetailsCRM)) {
       listaKonsultantow = from k in context.Konsultancis
                                                   select k;
}

Can I somehow extract context that was used from Konsultanci object later on so I don't have to store context on top of the class?

 foreach (Konsultanci test in listaKonsultantow) {
       // get context here? 
 }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
182 views
Welcome To Ask or Share your Answers For Others

1 Answer

Since you dispose your context at the end of the using block you should not even try.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...