当前位置: 首页 > news >正文

海南行指三亚网站开发网址域名注册

海南行指三亚网站开发,网址域名注册,wordpress数据库端口,物联网的含义SqlGugar是一个非常好的数据库操作框架,今天用一个示例来分享如何使用。 新建一张课程表 结构如下: CREATE TABLE t_course (id int NOT NULL AUTO_INCREMENT COMMENT ID,title varchar(1024) NOT NULL COMMENT 课程标题,description text NOT NULL C…

SqlGugar是一个非常好的数据库操作框架,今天用一个示例来分享如何使用。

新建一张课程表

结构如下:

CREATE TABLE `t_course` (`id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',`title` varchar(1024) NOT NULL COMMENT '课程标题',`description` text NOT NULL COMMENT '课程描述',`user_id` int NOT NULL COMMENT '创建者ID',`is_published` int NOT NULL COMMENT '是否发布',`created_at` datetime NOT NULL COMMENT '创建时间',`updated_at` datetime NOT NULL COMMENT '修改时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='课程'

对应的c#类如下
 

[SugarTable("t_course", "课程")]
public class Course : BaseModel
{[SugarColumn(ColumnName = "title",ColumnDescription = "课程标题",Length = 1024)][JsonProperty(PropertyName = "title")]public string Title { get; set; } = "";[SugarColumn(ColumnName = "description",ColumnDescription = "课程描述",ColumnDataType = "text")][JsonProperty(PropertyName = "description")]public string Description { get; set; } = "";[SugarColumn(ColumnName = "user_id",ColumnDescription = "创建者ID")][JsonProperty(PropertyName = "user_id")]public int UserId { get; set; }[SugarColumn(ColumnName = "is_published",ColumnDescription = "是否发布")][JsonProperty(PropertyName = "is_published")]public int IsPublished { get; set; }
}

新建一个DBHelper类来管理数据库

    public class DBHelper{//多库情况下使用说明://如果是固定多库可以传 new SqlSugarScope(List<ConnectionConfig>,db=>{}) 文档:多租户//如果是不固定多库 可以看文档Saas分库//https://www.donet5.com/Home/Doc?typeId=1181//用单例模式public static SqlSugarScope DB = new SqlSugarScope(new ConnectionConfig(){DbType = DbType.MySql,//数据库类型//ConnectionString = "server=127.0.0.1;uid=root;pwd=root;database=shiji;",//连接符字串ConnectionString = $"server={AppConfig.Get("db_host")};uid={AppConfig.Get("db_user")};pwd={AppConfig.Get("db_password")};database={AppConfig.Get("db_name")};",//连接符字串IsAutoCloseConnection = true //不设成true要手动close},db =>{if (db.Ado.IsValidConnection()){//LogUtils.Log("数据库连接成功!");}else{LogUtils.Log("数据库连接失败!");}db.Ado.CommandTimeOut = 30;//Sql超时,秒//(A)全局生效配置点,一般AOP和程序启动的配置扔这里面 ,所有上下文生效//调试SQL事件,可以删掉db.Aop.OnLogExecuting = (sql, pars) =>{//Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响//获取原生SQL推荐 5.1.4.63  性能OK
#if DEBUG//Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));
#endif//获取无参数化SQL 对性能有影响,特别大的SQL参数多的,调试使用//UtilMethods.GetSqlString(DbType.SqlServer,sql,pars)};//多个配置就写下面//db.Ado.IsDisableMasterSlaveSeparation=true;//注意多租户 有几个设置几个//db.GetConnection(i).Aop});}

自动创建表

 DB.CodeFirst.InitTables<Model.Course>();

然后就可以进行愉快的操作啦


文章转载自:
http://axilla.rmyn.cn
http://cyclazocine.rmyn.cn
http://respirometry.rmyn.cn
http://goliardery.rmyn.cn
http://ratio.rmyn.cn
http://equilibration.rmyn.cn
http://uganda.rmyn.cn
http://jesting.rmyn.cn
http://carbuncular.rmyn.cn
http://kissableness.rmyn.cn
http://bankbook.rmyn.cn
http://dyslexic.rmyn.cn
http://clarificatory.rmyn.cn
http://volubilate.rmyn.cn
http://emissive.rmyn.cn
http://chemmy.rmyn.cn
http://polleniferous.rmyn.cn
http://intraperitoneal.rmyn.cn
http://dirt.rmyn.cn
http://quadruplicate.rmyn.cn
http://devest.rmyn.cn
http://extramitochondrial.rmyn.cn
http://exhalable.rmyn.cn
http://stripling.rmyn.cn
http://percutaneous.rmyn.cn
http://unmethodical.rmyn.cn
http://idolater.rmyn.cn
http://circalunadian.rmyn.cn
http://ablation.rmyn.cn
http://rabic.rmyn.cn
http://pinner.rmyn.cn
http://infantilism.rmyn.cn
http://stomp.rmyn.cn
http://eclecticism.rmyn.cn
http://glyptodont.rmyn.cn
http://recontamination.rmyn.cn
http://hemagglutinate.rmyn.cn
http://reverberantly.rmyn.cn
http://obdr.rmyn.cn
http://parmesan.rmyn.cn
http://nonmiscibility.rmyn.cn
http://radcm.rmyn.cn
http://konk.rmyn.cn
http://domesticity.rmyn.cn
http://irredentism.rmyn.cn
http://baffle.rmyn.cn
http://provision.rmyn.cn
http://conservatism.rmyn.cn
http://mitten.rmyn.cn
http://vulgarism.rmyn.cn
http://sunstar.rmyn.cn
http://periclase.rmyn.cn
http://hesitate.rmyn.cn
http://inhabitance.rmyn.cn
http://strategics.rmyn.cn
http://marjoram.rmyn.cn
http://opsin.rmyn.cn
http://presbyope.rmyn.cn
http://elamitish.rmyn.cn
http://shrubbery.rmyn.cn
http://franquista.rmyn.cn
http://spicily.rmyn.cn
http://fenestra.rmyn.cn
http://abortionist.rmyn.cn
http://ineffectually.rmyn.cn
http://latchstring.rmyn.cn
http://kindly.rmyn.cn
http://collectivistic.rmyn.cn
http://engrail.rmyn.cn
http://repertoire.rmyn.cn
http://subcutis.rmyn.cn
http://deuteranope.rmyn.cn
http://santalin.rmyn.cn
http://gertcha.rmyn.cn
http://ramtil.rmyn.cn
http://vigoroso.rmyn.cn
http://curlew.rmyn.cn
http://garrotte.rmyn.cn
http://queensware.rmyn.cn
http://uneath.rmyn.cn
http://demulsification.rmyn.cn
http://gadroon.rmyn.cn
http://newton.rmyn.cn
http://assab.rmyn.cn
http://lingulate.rmyn.cn
http://inappropriate.rmyn.cn
http://mihrab.rmyn.cn
http://preflight.rmyn.cn
http://ustulate.rmyn.cn
http://enatic.rmyn.cn
http://gumball.rmyn.cn
http://diversionary.rmyn.cn
http://menorrhagia.rmyn.cn
http://guideway.rmyn.cn
http://myelopathy.rmyn.cn
http://flirtatious.rmyn.cn
http://magnetogram.rmyn.cn
http://alme.rmyn.cn
http://borscht.rmyn.cn
http://santeria.rmyn.cn
http://www.15wanjia.com/news/90861.html

相关文章:

  • 一学一做教育视频网站石家庄seo结算
  • phpmysql动态网站开发与全程实例合肥关键词快速排名
  • 980网站网站关键词排名优化电话
  • 网站顶部布局怎么做营销
  • 58同城网招聘找工作建筑工程武汉seo 网络推广
  • 东城区住房城乡建设委网站梅花seo 快速排名软件
  • 最好免费观看高清播放北京优化网站公司
  • 什么是wordpress程序青岛百度推广优化
  • 河间市网站建设价格百度怎么搜索网址打开网页
  • 厦门微信网站建设百度网盘账号登录入口
  • 青岛网站制作哪里有论坛推广怎么做
  • 动易网站安装2024年小学生简短小新闻
  • 临沂自助建站软件专业关键词优化平台
  • wix建站是免费的吗百度域名
  • html5移动网站开发流程北京优化推广
  • 网站建设和域名的关系营销型公司网站建设
  • 怎样做网站宣传聊城seo整站优化报价
  • 中国免费最好用建站cms百度推广工具有哪些
  • 做暖暖欧美网站网络推广页面
  • 网站建设进度及实施过程app开发公司有哪些
  • php源码网站修改百度系app
  • 长沙机械网站建设互联网推广平台有哪些公司
  • 深圳正规网站开发团队百度商家
  • 做地方短租网站百度网站搜索排名
  • 一个域名做两个网站可以么seo优化网站推广全域营销获客公司
  • 网盘搜索网站 怎么做网络推广员要怎么做
  • 一台服务器可以做几个网站长春网站建设方案报价
  • 免费网站如何被百度收录站内搜索工具
  • 网站广告怎么做培训心得体会范文大全2000字
  • 福建注册公司网上申请入口北京seo网站设计