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

wordpress 上传主题网站建设优化两千字

wordpress 上传主题,网站建设优化两千字,餐饮vi设计案例欣赏,做好网站建设工作总结目录 一、配置 二、操作步骤 1、根据配置映射数据库对象 2、实体配置 3、创建表 4、增删改查 增加数据 删除数据 更新数据 查询数据 5、导航增删改查 增加数据 删除数据 更新数据 查询数据 6、雪花ID 三、工具 SqlLite可视化工具 MySQL安装包 MySQL可视化…目录 一、配置 二、操作步骤 1、根据配置映射数据库对象 2、实体配置 3、创建表 4、增删改查  增加数据  删除数据 更新数据 查询数据 5、导航增删改查 增加数据 删除数据 更新数据 查询数据 6、雪花ID 三、工具 SqlLite可视化工具 MySQL安装包 MySQL可视化工具 SqlServer安装 SqlSugar官方文档https://www.donet5.com/Home/Doc?typeId2308  一、配置 1、Nuget包添加SqlSugar 2、App.config添加配置 ?xml version1.0 encodingutf-8 ? configurationstartup supportedRuntime versionv4.0 sku.NETFramework,Versionv4.7.2 //startupconnectionStrings!--sqlite数据库字符串路径符号|DataDirectory|代表当前运行目录--add namesqlite providerNameSystem.Data.SQLite connectionStringData Source|DataDirectory|\TestData.db;Version3; /!--Sqlserver数据库的连接字符串--add namesqlserver providerNameSystem.Data.SqlClient connectionStringPersist Security InfoFalse;Data Source(local);Initial CatalogTestData;Integrated SecuritySSPI /!--MySQL数据库的连接字符串--add namemysql providerNameMySql.Data.MySqlClient connectionStringServerlocalhost;DatabaseTestData;Uidroot;Pwd123456;SslModenone /!--PostgreSQL数据库的连接字符串--add namenpgsql providerNameNpgsql connectionStringServerlocalhost;Port5432;DatabaseTestData;User Idroot;Password123456 /!--不受驱动影响32位64位均可使用--add nameoracle providerNameOracleManaged connectionStringData Source(DESCRIPTION(ADDRESS(PROTOCOLTCP)(HOSTlocalhost)(PORT1521))(CONNECT_DATA(SERVERDEDICATED)(SERVICE_NAMEorcl)));User IDauston;Password123456 /!--达梦数据库的连接字符串--add nameDm providerNameDm connectionStringServerlocalhost;User IDauston;PWD123456;DatabaseCSPData; //connectionStringsappSettings!--指定默认的数据库类型如果不指定则使用第一个连接字符串--add keyDbType valuesqlite /add keyClientSettingsProvider.ServiceUri value //appSettings /configuration 二、操作步骤 1、根据配置映射数据库对象 private void Connect(){try{var db ConfigurationManager.AppSettings.Get(DbType);var connectStr ConfigurationManager.ConnectionStrings[db].ConnectionString;DbType dbType DbType.Sqlite;switch (db){case sqlite:dbType DbType.Sqlite;break;case mysql:dbType DbType.MySql;break;case sqlserver:dbType DbType.SqlServer;break;}sqlSugarScope new SqlSugarScope(new ConnectionConfig(){ConnectionString connectStr,DbType dbType,IsAutoCloseConnection true,//自动释放数据务如果存在事务在事务结束后释放InitKeyType InitKeyType.Attribute,//从实体特性中读取主键自增列信息});}catch (Exception){}} 2、实体配置 TableName指定表名不指定默认类名  ColumnName指定列名不指定默认属性名 IsPrimaryKey是否设为主键 [SugarTable(TableName Student)]public class Student{[SugarColumn(ColumnName ID,IsPrimaryKey true)]public string Id { get; set; }[SugarColumn(ColumnName Name)]public string Name { get; set; }} 3、创建表 private void CreateTable(int len, params Type[] types){//设置varchar的默认长度sqlSugarScope.CodeFirst.SetStringDefaultLength(len);//sqlSugarScope.CodeFirst.BackupTable().InitTables(types);//备份表sqlSugarScope.CodeFirst.InitTables(types);} 4、增删改查  增加数据  private void AddOne(Student stu){sqlSugarScope.InsertableStudent(stu).ExecuteCommand();} 删除数据 private void Delete(int id) {sqlSugarScope.DeleteableStudent().Where(ss.Id.Equals(id)).ExecuteCommand(); } 更新数据 private void Update(Student stu){//根据主键更新sqlSugarScope.UpdateableStudent(stu).ExecuteCommand();//据主键更新指定列//sqlSugarScope.UpdateableStudent(stu).UpdateColumns(i new { i.Id,i.Name}).ExecuteCommand();//根据指定列更新//sqlSugarScope.UpdateableStudent(stu).WhereColumns(inew { i.Name}).ExecuteCommand();//根据指定条件更新//sqlSugarScope.UpdateableStudent(stu).Where(i i.Age.Equals(18)).ExecuteCommand();//据主键更新忽略指定列//sqlSugarScope.UpdateableStudent(stu).IgnoreColumns(inew { i.Age}).ExecuteCommand();} 查询数据 var stus sqlSugarScope.QueryableStudent().Where(i i.Age.Equals(22)).ToList(); 5、导航增删改查 增加数据 NavigateType指定导航类型 nameof()绑定Id用于导航 IsIdentity是否自增 private void AddNav(){var books1 new ListBook(){new Book(){ NameBookA},new Book(){ NameBookB},new Book(){ NameBookC},};var books2 new ListBook(){new Book(){ NameBookK},new Book(){ NameBookP},new Book(){ NameBookZ},};sqlSugarScope.InsertNavStudent(new Student() { Name GGBom, Books books1 }).Include(i i.Books).ExecuteCommand();sqlSugarScope.InsertNavStudent(new Student() { Name LuBi, Books books2 }).Include(i i.Books).ExecuteCommand();}[SugarTable(TableName Student)]public class Student{[SugarColumn(ColumnName ID, IsPrimaryKey true, IsIdentity true)]public int Id { get; set; }public string Name { get; set; }public int Age { get; set; }[Navigate(NavigateType.OneToMany, nameof(Book.StudentId))]public ListBook Books { get; set; }}public class Book{[SugarColumn( IsPrimaryKey true, IsIdentity true)]public int BookId { get; set; }public string Name { get; set; }public int StudentId { get; set; }} 删除数据 private void DeleteNav(int age) {sqlSugarScope.DeleteNavStudent(i i.Age.Equals(age)).Include(m m.Books).ExecuteCommand(); } 更新数据 private void UpdateNav(){var books new ListBook(){new Book(){ NameBookNew1},new Book(){ NameBookNew2},new Book(){ NameBookNew3},};sqlSugarScope.UpdateNavStudent(new Student() {Id1, NameLucy,Booksbooks}).Include(i i.Books).ExecuteCommand();} 查询数据 var stus sqlSugarScope.QueryableStudent().Where(i i.Age.Equals(22)).Includes(i i.Books).ToList(); 6、雪花ID 设置WorkId //程序启时动执行一次就行//从配置文件读取一定要不一样//服务器时间修改一定也要修改WorkIdSnowFlakeSingle.WorkId 1;long类型主键自动赋值 [SugarColumn(ColumnName ID, IsPrimaryKey true)] public long Id { get; set; }//long类型的主键会自动赋值 long没有19位长度序列化雪花ID时要序列化成string  [Newtonsoft.Json.JsonConverter(typeof(ValueToStringConverter))] [SugarColumn(ColumnName ID, IsPrimaryKey true)] public long Id { get; set; }//long类型的主键会自动赋值 插入返回雪花ID long id db.Insertable(实体).ExecuteReturnSnowflakeId();//单条插入返回雪花ID ListLong idsdb.Insertable(List实体).ExecuteReturnSnowflakeIdList();//多条插入批量返回,比自增好用 手动调雪花ID var idSnowFlakeSingle.Instance.NextId();//也可以在程序中直接获取ID 自定义雪花算法 //程序启动时执行一次就行StaticConfig.CustomSnowFlakeFunc () {return 你的雪花ID方法();}; 三、工具 SqlLite可视化工具 链接 https://pan.baidu.com/s/1gCkYh2lxduUUKFIj5HHH8w 提取码: xvsc  MySQL安装包 链接:   https://pan.baidu.com/s/1X9HCtp4sMI9C0XAnBtpi5A 提取码: 97uh  MySQL可视化工具 链接:  https://pan.baidu.com/s/1ij42YorBtK96gwhLVNeopw 提取码: 1afx  SqlServer安装 链接:  https://pan.baidu.com/s/1od-s97LzlqrUnX3o8inoJQ 提取码: i5sj
http://www.hkea.cn/news/14432242/

相关文章:

  • 域名解析网站广州必去的景点排名
  • 网站后台管理系统框架有用模板网在线制作免费网站
  • 网站建设属于营业范围里的哪一项网络营销产品策略分析
  • 台州网站建设选浙江华企建设了湛江市志愿服务网站
  • 如何做网站的教程二维码关于单位建设网站的申请
  • 重庆网站租赁空间怎么做企业网站
  • 电商网站首页开发中国交通建设集团有限公司董事长
  • 建设中医知识学习网站wordpress首页显示友链
  • 网站建设征收文化事业建设费吗wordpress好用的富文本编辑器
  • 自己做的网站怎么设置信息必填建立网站目录结构时应该注意哪几个方面
  • 无锡工厂网站建设平面设计培训网
  • 做网站还需要兼容ie8吗做优惠卷网站倒闭了多少钱
  • 建站公司网站源码惠州网站公司
  • 网站有哪些区别是什么wordpress 微信采集插件
  • 二维码网站制作小游戏中心
  • 用wordpress做音乐网站设计制作建筑模型教案
  • 福建省建设监理网官方网站数字媒体艺术就业方向
  • 创建一个网站的技术营销网络建设四个阶段
  • 怎么给网站添加音乐平面设计案例网站
  • 深圳人才网站建设网站建设工作室介绍范文
  • 合肥商务科技学校网站建设seo网络优化是做什么的
  • wordpress弹出公告网站内容很少如何做seo
  • 宁夏网站建设费用地址汕头专业网页设计培训哪个好
  • 沈阳微信网站建设网站空间密码
  • 天台城乡规划建设局网站苏州网站快速推广
  • 佛山网站建设拓客科技国际设计公司logo
  • 做养生产品哪个网站好网站开发+协作平台
  • 网站域名的选择方法wordpress调整语言
  • 企业网站打包下载wordpress 删除自豪
  • 哪个网站可以做兼职wordpress安装没反应