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

在线转格式网站怎么做微信开放平台帐号

在线转格式网站怎么做,微信开放平台帐号,免费做头像网站有哪些,如何建响应式网站一、安装 第一步,在你的项目中找到解决方案,右键-管理解决方案的Nuget 第二步,下载对应的包,注意你的框架是哪个就下载哪个的包,一个项目安装一次包即可 点击应用和确定 安装好后会显示sqlsugar的包 二、使用&#xf…

一、安装

第一步,在你的项目中找到解决方案,右键-管理解决方案的Nuget

第二步,下载对应的包,注意你的框架是哪个就下载哪个的包,一个项目安装一次包即可

点击应用和确定

安装好后会显示sqlsugar的包

二、使用:增删改查

using SqlSugar;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;[SugarTable("TestTable")] // 指定实体类对应的数据库表名
class TestTable
{[SugarColumn(IsPrimaryKey = true)] // 指定主键列public string Id { get; set; }public string Name { get; set; }public int Age { get; set; }public string Content { get; set; }public int IsEnable { get; set; }public int IsDeleted { get; set; }public string Stage { get; set; }public string Remarks { get; set; }
}class Test
{public static int AddOrUpdate<T>(SqlSugarClient db,T entity) where T : class, new(){var entityIdProp = GetEntityIdProperty<T>();var entityIdValue = entityIdProp.GetValue(entity);var dbEntity = db.Queryable<T>().InSingle(entityIdValue);if (dbEntity != null){// 根据 ID 查询到了记录,执行更新操作return db.Updateable(entity).ExecuteCommand();}else{// 根据 ID 没有查询到记录,执行插入操作return db.Insertable(entity).ExecuteCommand();}}public static PropertyInfo GetEntityIdProperty<T>() where T : class, new(){var entityType = typeof(T);var properties = entityType.GetProperties();foreach (var property in properties){var attribute = Attribute.GetCustomAttribute(property, typeof(SqlSugar.SugarColumn)) as SqlSugar.SugarColumn;if (attribute != null && attribute.IsPrimaryKey){return property;}}throw new Exception($"实体类型 {entityType.FullName} 没有定义主键");}static void Main(string[] args){// 创建 SqlSugar 实例SqlSugarClient db = new SqlSugarClient(new ConnectionConfig(){ConnectionString = "server = DESKTOP-FTH2P3S; Database = TestDb; Trusted_Connection = SSPI;", // 数据库连接字符串DbType = DbType.SqlServer, // 数据库类型IsAutoCloseConnection = true, // 是否自动关闭数据库连接});// 1.插入数据var model = new TestTable(){Id = Guid.NewGuid().ToString(),Name = "Tom",Age = 18,Content = "Hello World",IsEnable = 1,IsDeleted = 0,Stage = "Stage 1",Remarks = "Test"};int insert_code = db.Insertable(model).ExecuteCommand();//返回影响行数// 2.查询数据var list = db.Queryable<TestTable>().ToList();// 3.自定义查询SQLvar result = db.SqlQueryable<TestTable>("SELECT * FROM TestTable WHERE Age > 30").ToList();// 4.更新数据var updateModel = db.Queryable<TestTable>().Where(it => it.Id == "8ffd64fc-8aea-4641-a57b-d957ad0dd229").First();if (updateModel != null){updateModel.Name = "Jerry";var update_code = db.Updateable(updateModel).ExecuteCommand();//返回影响行数}// 5.删除数据var delete_code = db.Deleteable<TestTable>().Where(it => it.Id == "8ffd64fc-8aea-4641-a57b-d957ad0dd229").ExecuteCommand();//返回影响行数//6.自主封装的方法,有则添加无则插入(根据主键ID匹配)var updateModel2 = new TestTable();updateModel2.Id = "8ffd64fc-8aea-4641-a57b-d957ad0dd229";updateModel2.Name = "SuSu";int a = AddOrUpdate<TestTable>(db, updateModel2);//返回影响行数}
}

【备注】AddOrUpdate是自己写的方法。

http://www.yayakq.cn/news/791998/

相关文章:

  • 企业网站建站的专业性原则是指wordpress推介链接插件
  • 杭州开发区建设局网站wordpress边栏扩大尺寸
  • 农产品的网站建设方案书范文做1元夺宝网站挣钱吗
  • 自学网站建设哪个网站好校园推广方案经典范文
  • 做网站能自己找服务器吗手机建网站公司
  • wordpress 网站投票网站上的文章用秀米可以做吗
  • 湖北省南漳县城乡建设局网站网页设计案例欣赏
  • 温州网站制作报价怎样做医疗保健网站
  • 0311网站建设wordpress 域名邮箱
  • c 语言能开发做网站吗施工企业会计核算特点
  • 广东专业网站建设二级域名免费发放
  • 网站建设 APP开发销售怎么做朝阳网站seo
  • 做电影网站考什么wordpress首页名称
  • 信息技术网站建设教案word可以制作网页
  • 温州专业微网站制作电话有没有做线播放网站
  • 昆明网站建设服务长春建站模板搭建
  • 北京好的建站团队公司的网站续费
  • 郑州企业网站设计seo权重查询
  • 购物网站排名天商阳光网站邮箱
  • 公司网页如何建立泉州seo按天收费
  • 100个万能网站wordpress 版本查询
  • 六安网站制作人才招聘crm在线演示
  • 移动网站 模板介绍东莞网站建设的ppt
  • 短视频网站开发上海网站建设导航
  • 如何查看网站服务器系统电商是做什么
  • 访问国外网站好慢网络营销方式多样
  • wordpress增加额外链接电商网站建设优化
  • seo现在还有前景吗seo服务套餐
  • 手机p2p网站开发免费咨询保险
  • 重庆专业网站建设公司排名手机评测网