PDA

View Full Version : سوال: سوال درباره EntityFramwork4



hastiam
چهارشنبه 01 آذر 1391, 14:59 عصر
سلام دوستان من از EntityFramwork4 برای ارتباط با دیتابیس استفاده می کنم وقتی تعداد کاربرانی که همزمان از سیستم استفاده می کنند بیشتر از 10 تا شود خطای زیر را می دهد::گریه:
The connection was not closed. The connection's current state is connecting
برای حل این مشکل چیکار باید کرد؟
این مشکل هم زمانی ایجاد می شه که بخوام لیستی از اطلاعات یک جدول را بگیرم مثلا به صورت زیر :


var list = (context.Goods).ToList();

tooraj_azizi_1035
پنج شنبه 02 آذر 1391, 18:26 عصر
کدت رو در بلوک using بذار(جواب در فروم مایکروسافت بود):


I spent some time over the weekend, and found that wrapping my LINQ queries with a "using" clause helped my situation.

using db as new myContext()

.. linq query ..

end using

As long as I extracted a single entity, or a list(of entity) it seems to work. If I tried extracting an Iqueryable and use it outside the "using" statement, I ended up with the same error.

Thanks and good luck on your future projects!

hastiam
دوشنبه 06 آذر 1391, 12:33 عصر
ممنونم از راهنماییتون
من اومدم از دستوری که گفتید استفاده کردم اما وقتی صفحه در حال باز شدن هست خطای زیر رو میده ::افسرده::افسرده:
The operation cannot be completed because the DbContext has been disposed

دلیلش چی می تونه باشه؟