小编Joe*_*oeG的帖子

Net Core Connection String Dapper视觉工作室2017

我试图在我的.Net Core应用程序中设置连接字符串,但我一直收到错误:

System.NullReferenceException:'对象引用未设置为对象的实例.'

我尝试将以下内容添加到appsettings.json:

"ConnectionStrings": {

"Analysis": "Server=DESKTOP-MYSERVER;Database=MYDATABASE;User Id=sa; Password=Password123;Provider=System.Data.SqlClient;Trusted_Connection=True;MultipleActiveResultSets=true;Pooling=false;"
}
Run Code Online (Sandbox Code Playgroud)

我也试过像以前那样使用web.config .Net Core:

<connectionStrings>
<add name="Analysis" providerName="System.Data.SqlClient" 
     connectionString="Server=DESKTOP-MYSERVER;Database=MYDATABASE;User Id=sm;Password=Password123;"/>
Run Code Online (Sandbox Code Playgroud)

然后在c#我有:

public List<DapperTest> ReadAll()
    {
        var data = new List<DapperTest>();
        using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["Analysis"].ConnectionString))
        {
             data = db.Query<DapperTest>("select * from testTable").ToList();
        }

        return data;
    }
Run Code Online (Sandbox Code Playgroud)

两种方式都给我例外:

System.NullReferenceException:'对象引用未设置为对象的实例.'

我使用了以下资源:

.Net CORE Dapper连接字符串?

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro

从App.config获取连接字符串

但我错过了一些东西.我只设置了一次连接字符串,它不在.Net Core中,因此对其他人来说可能是显而易见的.

c# asp.net asp.net-mvc dapper .net-core

7
推荐指数
1
解决办法
5914
查看次数

VIM YouCompleteMe 错误 - NoExtraConfDetected: 未检测到 .ycm_extra_conf.py 文件

我正在为 C++ 设置 YouCompleteMe,但是当我打开 .cpp 文件时,出现错误 NoExtraConfDetected: No .ycm_extra_conf.py file detector

.vimrc 文件如下所示:

set nocompatible " be iMproved, required filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required

Plugin 'VundleVim/Vundle.vim'

Plugin 'rdnetto/YCM-Generator'

Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = '$USER/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

" All of your Plugins must be added before the following line
call vundle#end() " …
Run Code Online (Sandbox Code Playgroud)

c++ linux vim

5
推荐指数
1
解决办法
8070
查看次数

标签 统计

.net-core ×1

asp.net ×1

asp.net-mvc ×1

c# ×1

c++ ×1

dapper ×1

linux ×1

vim ×1