در متن آمده که EF Core به صورت پیش فرض ، Db Context را به صورت Scoped ثبت میکند. و نحوه تزریق از طریق سازنده کلاسها است. از طرفی اگر درست متوجه شده باشم در مستندات ماکروسافت هشدار داده شده که این مدل طول حیات را نباید از طریق سازنده تزریق کرد.
When using a scoped service in a middleware, inject the service into the Invoke or InvokeAsync method. Don't inject via constructor injection because it forces the service to behave like a singleton. For more information, see Write custom ASP.NET Core middleware.
همچنین شما گفتید که "سرویسهای Scoped در محدودهی درخواست، مانند Singleton عمل میکنند و شیء ساخته شده و وضعیت آن در بین تمامی سرویسهایی که به آن نیاز دارند، مشترک است. بنابراین باید به این نکته در هنگام تعریف سرویس به صورت Scoped ، توجه داشته باشید."
در پروژهای که روی آن کار میکنم (ASP.NET Core Razor Pages) یک کلاس validation هست که میخوام به عنوان یک سرویس به کلاس هر صفحه تزریق بشه. اگر امکانش هست توضیح بدید که بر اساس مواردی که در بالا آوردم و هدفی که دارم آیا بین حالات singleton و scoped فرقی وجود دارد؟
ممنون.
Improved the MSBuild selection logic. The standalone instance inside OmniSharp is now preferred over VS2017, with VS2019 given the highest priority. This ensures that .NET Core 3.0 works correctly. It is also possible manually provide an MSBuild path using OmniSharp configuration, which is then always selected. (omnisharp-roslyn#1541, PR: omnisharp-roslyn#1545)
{ "MSBuild": { "MSBuildOverride": { "MSBuildPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\15.0\\Bin", "Name": "vs2017 msbuild" } } }
دفتر کار باز ایده بسیار بدی است!
Not because there aren’t people who actually enjoy working in an open office, there are. Quite a few, actually. But they’re in the distinct minority. The vast majority of people either dislike the open office or downright hate it. So how is that going to work, exactly?
NET Core 3.0 Preview 8. منتشر شد
Today, we are announcing .NET Core 3.0 Preview 8. Just like with Preview 7, we’ve focused on polishing .NET Core 3.0 for a final release and are not adding new features. If these final previews seem anti-climatic, that’s by design.