.net-core-2.0

Session Store IQueryable in HttpContext

不羁的心 提交于 2020-01-03 03:05:22
问题 I am migrating project from Net MVC to MVC Core 2. How do I set IQueryable in Sessions? In Net MVC it was the following, public ActionResult CurrentOwners_Read([DataSourceRequest]DataSourceRequest request, int propertyID) { if (propertyID == 0) { throw new ArgumentNullException("propertyID"); } IQueryable<PropertyOwnerRoleViewModel> allResult = (IQueryable<PropertyOwnerRoleViewModel>)HttpContext.Session.GetString(_currentOwnersResult).AsQueryable(); if (allResult == null) {

Session Store IQueryable in HttpContext

孤者浪人 提交于 2020-01-03 03:05:16
问题 I am migrating project from Net MVC to MVC Core 2. How do I set IQueryable in Sessions? In Net MVC it was the following, public ActionResult CurrentOwners_Read([DataSourceRequest]DataSourceRequest request, int propertyID) { if (propertyID == 0) { throw new ArgumentNullException("propertyID"); } IQueryable<PropertyOwnerRoleViewModel> allResult = (IQueryable<PropertyOwnerRoleViewModel>)HttpContext.Session.GetString(_currentOwnersResult).AsQueryable(); if (allResult == null) {

SmtpAppender missing in log4net 2.0.8 nuget?

倖福魔咒の 提交于 2020-01-02 04:53:09
问题 I created a console app for .NET Core 2.0 and installed a log4net 2.0.8 nuget I want to use the SmtpAppender but it does not exist in the library This is my log4net configuration <?xml version="1.0" encoding="utf-8" ?> <log4net> <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> <to value="test@test.com" /> <from value="test@test.com" /> <subject type="log4net.Util.PatternString" value="Message logged" /> <smtpHost value="localhost" /> <authentication value="None" /> <port

Binding a configuration to an object graph in .NET Core 2.0

本小妞迷上赌 提交于 2020-01-02 01:15:25
问题 I'm making a .NET Core 2.0 app and I need to configure it. I'm looking at this documentation and it seems that in .NET Core 1.0 you could do: var appConfig = new AppSettings(); config.GetSection("App").Bind(appConfig); And in .NET Core 1.1 you could do: var appConfig = config.GetSection("App").Get<AppSettings>(); But neither Bind nor Get exist in .NET Core 2.0. What's the new way to achieve this? Thanks, Josh 回答1: You can still do both of these. Since you are in a console application, and as

Reference .netstandard 2.0 project in core 2.0 Runtime loading error when GenerateAssemblyInfo = false

喜欢而已 提交于 2019-12-31 05:08:05
问题 When we add the reference, we are able to use the .netstandard libs classes in our .net core console project (in Visual Studio), and it compiles. When we run the app, it immediately crashes with this error in the output window: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'MyNetStandard20Assembly, Version=0.1.0.0, Culture=en-us, PublicKeyToken=null'. The system cannot find the file specified. Update / Cause (still

Reference .netstandard 2.0 project in core 2.0 Runtime loading error when GenerateAssemblyInfo = false

和自甴很熟 提交于 2019-12-31 05:07:17
问题 When we add the reference, we are able to use the .netstandard libs classes in our .net core console project (in Visual Studio), and it compiles. When we run the app, it immediately crashes with this error in the output window: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'MyNetStandard20Assembly, Version=0.1.0.0, Culture=en-us, PublicKeyToken=null'. The system cannot find the file specified. Update / Cause (still

The DbContext of type cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions

雨燕双飞 提交于 2019-12-30 01:15:16
问题 I am trying to upgrade our current .Net Core application from 1.1 to 2.0 and am getting this runtime error: "The DbContext of type 'CoreContext' cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions". It is caused by using the new IServiceCollection.AddDbContextPool<> function. When I use IServiceCollection.AddDbContext<> it still works. This application is DB-First, so I generate all our contexts using 'Scaffold-DbContext'

How to create user defined functions using code first in ABP?

我的未来我决定 提交于 2019-12-24 11:29:49
问题 I want to create some user-defined functions using code first approach in abp framework. I have created stored procedures xyz by adding xyz.sql inside EntityFrameworkCore\Migrations\Stored Procedures folder, But not able to find a way to create a function, please help. 来源: https://stackoverflow.com/questions/48262776/how-to-create-user-defined-functions-using-code-first-in-abp

Net Core MVC: Name Session does not exist in Current Context

耗尽温柔 提交于 2019-12-24 10:57:03
问题 I am receiving an error in the last line. How would I resolve this? Trying to convert Net 4.6.2 Project to MVC Net Core. Last Line Error: Name Session does not exist in Current Context. public class TransferPropertyOwnershipController : Controller { public ActionResult GetNewOwnerRecord(int ownerID, int propertyID) { OwnerManager ownerManager = new OwnerManager(); var newOwner = ownerManager.Get(ownerID, true); PropertyOwnerRoleViewModel newPropertyOwnerRoleViewModel = new

Avoid logging twice using netcore2.0 on AWS Lambda with Serilog

大城市里の小女人 提交于 2019-12-24 06:25:22
问题 After upgrading my netcore project to 2.0, i see double logs when my application is running on AWS Lambda, which utilizes the Serilog framework. Please see my setup below: public void ConfigureServices(IServiceCollection services) { ... // Setup logging Serilog.Debugging.SelfLog.Enable(Console.Error); var logger = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext(); if (GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "").Equals("local")) logger.WriteTo.Console(); else