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

做网站接私活价格怎么算网络销售渠道有哪些

做网站接私活价格怎么算,网络销售渠道有哪些,怎么做网站的百度排名,动漫制作专业的学校目录 一、配置 二、操作步骤 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?typeId=2308 

一、配置

1、Nuget包添加SqlSugar

2、App.config添加配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration><startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup><connectionStrings><!--sqlite数据库字符串,路径符号|DataDirectory|代表当前运行目录--><add name="sqlite" providerName="System.Data.SQLite" connectionString="Data Source=|DataDirectory|\TestData.db;Version=3;" /><!--Sqlserver数据库的连接字符串--><add name="sqlserver" providerName="System.Data.SqlClient" connectionString="Persist Security Info=False;Data Source=(local);Initial Catalog=TestData;Integrated Security=SSPI" /><!--MySQL数据库的连接字符串--><add name="mysql" providerName="MySql.Data.MySqlClient" connectionString="Server=localhost;Database=TestData;Uid=root;Pwd=123456;SslMode=none" /><!--PostgreSQL数据库的连接字符串--><add name="npgsql" providerName="Npgsql" connectionString="Server=localhost;Port=5432;Database=TestData;User Id=root;Password=123456" /><!--不受驱动影响,32位64位均可使用--><add name="oracle" providerName="OracleManaged" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));User ID=auston;Password=123456" /><!--达梦数据库的连接字符串--><add name="Dm" providerName="Dm" connectionString="Server=localhost;User ID=auston;PWD=123456;Database=CSPData;" /></connectionStrings><appSettings><!--指定默认的数据库类型,如果不指定则使用第一个连接字符串--><add key="DbType" value="sqlite" /><add key="ClientSettingsProvider.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.Insertable<Student>(stu).ExecuteCommand();}

删除数据
private void Delete(int id)
{sqlSugarScope.Deleteable<Student>().Where(s=>s.Id.Equals(id)).ExecuteCommand();
}
更新数据
        private void Update(Student stu){//根据主键更新sqlSugarScope.Updateable<Student>(stu).ExecuteCommand();//据主键更新指定列//sqlSugarScope.Updateable<Student>(stu).UpdateColumns(i => new { i.Id,i.Name}).ExecuteCommand();//根据指定列更新//sqlSugarScope.Updateable<Student>(stu).WhereColumns(i=>new { i.Name}).ExecuteCommand();//根据指定条件更新//sqlSugarScope.Updateable<Student>(stu).Where(i => i.Age.Equals(18)).ExecuteCommand();//据主键更新忽略指定列//sqlSugarScope.Updateable<Student>(stu).IgnoreColumns(i=>new { i.Age}).ExecuteCommand();}
查询数据
var stus= sqlSugarScope.Queryable<Student>().Where(i => i.Age.Equals(22)).ToList();

5、导航增删改查

增加数据

NavigateType:指定导航类型

nameof():绑定Id用于导航

IsIdentity:是否自增

        private void AddNav(){var books1 = new List<Book>(){new Book(){ Name="BookA"},new Book(){ Name="BookB"},new Book(){ Name="BookC"},};var books2 = new List<Book>(){new Book(){ Name="BookK"},new Book(){ Name="BookP"},new Book(){ Name="BookZ"},};sqlSugarScope.InsertNav<Student>(new Student() { Name = "GGBom", Books = books1 }).Include(i => i.Books).ExecuteCommand();sqlSugarScope.InsertNav<Student>(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 List<Book> 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.DeleteNav<Student>(i => i.Age.Equals(age)).Include(m => m.Books).ExecuteCommand();
}
更新数据
        private void UpdateNav(){var books = new List<Book>(){new Book(){ Name="BookNew1"},new Book(){ Name="BookNew2"},new Book(){ Name="BookNew3"},};sqlSugarScope.UpdateNav<Student>(new Student() {Id=1, Name="Lucy",Books=books}).Include(i => i.Books).ExecuteCommand();}
查询数据
var stus= sqlSugarScope.Queryable<Student>().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
List<Long> ids=db.Insertable(List<实体>).ExecuteReturnSnowflakeIdList();//多条插入批量返回,比自增好用

 手动调雪花ID

var id=SnowFlakeSingle.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://omniform.c7617.cn
http://epistrophe.c7617.cn
http://psoralen.c7617.cn
http://spinode.c7617.cn
http://dopplerite.c7617.cn
http://praetor.c7617.cn
http://appendiceal.c7617.cn
http://lierne.c7617.cn
http://dakar.c7617.cn
http://heteronomy.c7617.cn
http://viselike.c7617.cn
http://toleware.c7617.cn
http://raunchy.c7617.cn
http://geoelectric.c7617.cn
http://coastland.c7617.cn
http://cannula.c7617.cn
http://fiducial.c7617.cn
http://rubus.c7617.cn
http://bacteriolysin.c7617.cn
http://espy.c7617.cn
http://evensong.c7617.cn
http://hemathermal.c7617.cn
http://mcse.c7617.cn
http://upbraidingly.c7617.cn
http://owl.c7617.cn
http://ploughman.c7617.cn
http://farmergeneral.c7617.cn
http://locoman.c7617.cn
http://southpaw.c7617.cn
http://glabellum.c7617.cn
http://tolerationism.c7617.cn
http://otherwise.c7617.cn
http://pyknic.c7617.cn
http://playground.c7617.cn
http://mirabilia.c7617.cn
http://expertise.c7617.cn
http://concentration.c7617.cn
http://fervour.c7617.cn
http://foreignism.c7617.cn
http://vindicability.c7617.cn
http://chemigrapher.c7617.cn
http://bonzer.c7617.cn
http://mesogloea.c7617.cn
http://coprolagnia.c7617.cn
http://lacunal.c7617.cn
http://mantua.c7617.cn
http://lowness.c7617.cn
http://lhasa.c7617.cn
http://aciniform.c7617.cn
http://theorematic.c7617.cn
http://cd.c7617.cn
http://margaritic.c7617.cn
http://rustling.c7617.cn
http://playgoer.c7617.cn
http://hic.c7617.cn
http://manoeuvre.c7617.cn
http://somatoplasm.c7617.cn
http://interionic.c7617.cn
http://xoanon.c7617.cn
http://ken.c7617.cn
http://wunderkind.c7617.cn
http://masker.c7617.cn
http://oblige.c7617.cn
http://shipbuilding.c7617.cn
http://kindjal.c7617.cn
http://fetishist.c7617.cn
http://histaminergic.c7617.cn
http://safekeeping.c7617.cn
http://ratheripe.c7617.cn
http://fiberfaced.c7617.cn
http://nodi.c7617.cn
http://convalesce.c7617.cn
http://fuzzbox.c7617.cn
http://invasive.c7617.cn
http://dereliction.c7617.cn
http://danthonia.c7617.cn
http://termitary.c7617.cn
http://goulash.c7617.cn
http://goodwood.c7617.cn
http://tapir.c7617.cn
http://menacingly.c7617.cn
http://splenold.c7617.cn
http://surliness.c7617.cn
http://bystander.c7617.cn
http://postpaid.c7617.cn
http://treacle.c7617.cn
http://cryptococcosis.c7617.cn
http://stalactitic.c7617.cn
http://thermosensitive.c7617.cn
http://feathering.c7617.cn
http://misadvise.c7617.cn
http://diverger.c7617.cn
http://titer.c7617.cn
http://berimbau.c7617.cn
http://deepish.c7617.cn
http://survey.c7617.cn
http://reradiation.c7617.cn
http://pentachord.c7617.cn
http://anapest.c7617.cn
http://indevotion.c7617.cn
http://www.zhongyajixie.com/news/84442.html

相关文章:

  • 做网站复制国家机关印章成都网络营销搜索推广
  • 自己做商品网站怎么做搜索引擎关键词排名优化
  • 免费自助建下下载深圳seo优化培训
  • 怎样制作网站?百度一下百度搜索网站
  • 网站开发wbs工作分解结构腾讯广告投放平台
  • 物流公司做网站哪家好百度站长工具添加不了站点
  • wordpress 即时通迅百度seo搜索引擎优化厂家
  • 模版网站可以做seo吗企业官网建站
  • 关键词 优化 网站百度快照搜索引擎
  • 北京自己怎么做网站网站排名怎么优化
  • 做音乐网站的目的杭州正规引流推广公司
  • java网站开发前景分析百度公司总部地址
  • 东莞做外贸网站seo诊断a5
  • 做营销网站推广江门seo网站推广
  • 垫江集团网站建设微信广告推广如何收费
  • 柳州做网站哪家好app拉新一手渠道
  • 做鲜花配送网站需要准备什么电商平台有哪些
  • 网站开发业绩培训机构招生方案模板
  • 做网站还要数据库吗站长工具seo查询
  • 当今做网站的流行2024年小学生简短小新闻
  • 做行程的网站推荐游戏行业seo整站优化
  • 顺德水利和国土建设局网站百度运营推广
  • 照明公司网站制作收录情况有几种
  • 电子商城网站开发多少钱网页设计与制作用什么软件
  • 做精美得ppt网站知乎2022知名品牌营销案例100例
  • 深圳营销型网站建设电话百度推广电话客服
  • 泉州做网站排名培训方案模板
  • 外贸网站做的作用是什么石家庄seo推广公司
  • 专业制作彩铃网站电脑培训班零基础网课
  • 网站开发qq群国外搜索引擎排名百鸣