小标
2018-08-31
来源 :
阅读 1749
评论 0
摘要:本文主要向大家介绍了SQLServer数据库之.NETCore Sqlserver下对Dapper的扩展支持,通过具体的内容向大家展现,希望对大家学习SQLServer数据库有所帮助。
本文主要向大家介绍了SQLServer数据库之.NETCore Sqlserver下对Dapper的扩展支持,通过具体的内容向大家展现,希望对大家学习SQLServer数据库有所帮助。
这里我们自定义一个IServiceCollection的扩展,例如下面我的扩展
services.AddDapperContext(dapperoptions =>
{
dapperoptions.ConnectionString = "Data Source=192.168.0.42;Initial Catalog=NET.Core;User ID=sa;password=lym123!@#;Integrated Security=false";
});
添加了对数据库连接字符串设置,当然你也可以设置更多的参数,委托等等,这里简单演示下自定义dapper下的数据库访问,下面是扩展设置
1 public static class DapperMiddlewareExtension
2 {
3
4 public static IServiceCollection AddDapperContext
5 {
6 serviceCollection.Configure(optionsAction);
7 serviceCollection.AddTransient
8 serviceCollection.AddSingleton
9 return serviceCollection;
10 }
11 ///
14 ///
15 ///
16 ///
17 ///
18 ///
19 public static IServiceCollection AddDapperContext(this IServiceCollection serviceCollection, Action
本文由职坐标整理并发布,希望对同学们学习SQL Server有所帮助,更多内容请关注职坐标数据库SQL Server数据库频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号