sqlhelper

SugarSql的基本使用方法(1)

☆樱花仙子☆ 提交于 2020-05-04 13:24:19
using SqlSugar; using SqlSugar.Helper; using SqlSugar.Model; using System; using System.Collections.Generic; using System.Linq; namespace SugarSql { class Program { static void Main(string[] args) { SqlSugarClient db = new SqlHelper().CreateDB(); #region 新增 //int changeNum = db.Insertable(new User() { Name = "张三", Address = "NJ", Gender = "男", Birth = DateTime.Today }).ExecuteCommand(); //int addid = db.Insertable(new User() { Name = "李四", Address = "BJ", Gender = "女", Birth = DateTime.Today }).ExecuteReturnIdentity(); //List<User> users = new List<User>() //{ // new User() { Name = "Jerry",

从壹开始前后端分离【 .NET Core2.2/3.0 +Vue2.0 】框架之六 || API项目整体搭建 6.1 仓储+服务+抽象接口模式

孤街浪徒 提交于 2020-04-25 15:17:58
本文3.0版本文章 本文涉及的内容,同样适用于3.0版本,不用修改。 前言   书接上文:前几回文章中,我们花了三天的时间简单了解了下接口文档Swagger框架,已经完全解放了我们的以前的Word说明文档,并且可以在线进行调试,而且当项目开始之中,我们可以定义一些空的接口,或者可以返回假数据,这样真正达到了前后端不等待的缺陷,还是很不错的,当然,这离我说的前后端分离还是相差甚远,今天呢,我们就简单搭建下我们的项目架构。   本项目是我自己的一个真实项目,数据都是真实的,之前搭建过一个MVC + EF Code First的项目,本项目就是基于这个了,前一段时间我已经搭建起来了,是这样的,本系列教程会重新开始。 零、完成图中的 粉色 部分 先简单解释下各层之间的调用关系: 除了项目对外暴露的是 Api 展示层,和核心的实体 Model 层外, 仓储模块 (作为一个数据库管理员,直接操作数据库,实体模型): BaseRepository(基类仓储) 继承实现了 接口IBaseRepository,这里放公共的方法, AdvertisementRepostitory 继承 BaseRepository<Advertisement>, IAdvertisementRepository Service模块 (处理业务逻辑,可以直接使用ViewModel视图模型): BaseService

ADO.NET事务封装

痞子三分冷 提交于 2020-02-26 15:35:13
在数据库工具类编写的过程中,对事务的处理操作想避免各个原子操作的事务对象赋值重复操作,想对外暴露的方法为如下形式 public bool ExecuteTransition ( Action TransitionAction, out string ExceptionStr ) 外部传入的数据库操作都使用委托统一打包,内部进行事务操作。我们首先需要明白的是,数据库事务操作在ADO.NET的编码中的体现是,DbConnection为同一个,DbCommand的Transaction为同一个。 首先我们需要识每一个数据库操作的上下文,是否在TransitionAction这个委托中,为了简单明了,在执行TransitionAction时开启一个Task,取得当前线程的ThreadID作为这个事务委托的唯一标识,并生成一个DbTransaction放入一个TransactionDic中,在SqlHelper执行类中执行SQL语句创建Connection时,取得当前的ThreadID去TransactionDic中查找,如果有对应的Transition则说明该SQL语句的执行是在一个事务中,Connection直接取Transition的数据库连接,并给DbCommand的Transition对象赋值

SQLHelper.DB not passing parameters to stored procedure

这一生的挚爱 提交于 2020-01-16 10:11:47
问题 This is a new issue of my previous question (C# Using Parameters in SqlHelper.DB). If I pass null as the parameters and set the command text to a parameterless stored procedure, it works fine. SQLHelper.DB is executing the stored procedure but I get an error: Unhandled Exception: System.Data.SqlClient.SqlException: Procedure or function 'sptest' expects parameter '@param1', which was not supplied. This can be recreated by creating a new .NET 4.7.2 console app and installing Nuget package

SQLHelper.DB not passing parameters to stored procedure

穿精又带淫゛_ 提交于 2020-01-16 10:11:47
问题 This is a new issue of my previous question (C# Using Parameters in SqlHelper.DB). If I pass null as the parameters and set the command text to a parameterless stored procedure, it works fine. SQLHelper.DB is executing the stored procedure but I get an error: Unhandled Exception: System.Data.SqlClient.SqlException: Procedure or function 'sptest' expects parameter '@param1', which was not supplied. This can be recreated by creating a new .NET 4.7.2 console app and installing Nuget package

C# Using Parameters in SqlHelper.DB

北慕城南 提交于 2020-01-06 08:11:12
问题 I installed SqlHelper.DB NuGet package (https://www.nuget.org/packages/SQLHelper.DB/) and I am having issues passing parameters to the AddQuery method. I am passing a List of SqlParameter to my function and I receive an error: 'Failed to convert parameter value from a List`1 to a Int32.' Here is the code to call my method: SqlProcessor sqlproc = new SqlProcessor("Data Source = myserver; Initial Catalog = mydb; User ID = me; Password = $uper$ecret;"); List<SqlParameter> p = new List

Timeout issue when using sql helper(Microsoft.ApplicationBlocks.Data)

谁说胖子不能爱 提交于 2019-12-14 03:46:31
问题 I am having timeout issues when dealing with long sql queries, the Dataset which timesout for long queries is : static public DataSet Getxxxx(Guid xxxx) { DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "GetAllxx", new SqlParameter("@productxx", productxx)); return ds; } Where can i set timeout , I am using Microsoft application block version 2.0. 回答1: The Data Access Application Block SqlHelper has been phased out in favour of 'Database', so you'll need

SQLHelper Class

我的梦境 提交于 2019-12-01 06:51:23
Is there a recent version of the SQLHelper class out there. I've been using one for a few years now and was wondering if there is a new version out there for .NET Framework 2.0 or 3.0. I prefer this on small projects vs Microsoft Data App Block (which I use on larger projects). I came across this link http://www.microsoft.com/downloads/details.aspx?familyid=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en According to this ... SqlHelper was actually replaced with an abstract class, called Database, and two concrete classes that derive from it: SqlDatabase and OracleDatabase. To follow up on

SQLHelper Class

扶醉桌前 提交于 2019-12-01 05:54:36
问题 Is there a recent version of the SQLHelper class out there. I've been using one for a few years now and was wondering if there is a new version out there for .NET Framework 2.0 or 3.0. I prefer this on small projects vs Microsoft Data App Block (which I use on larger projects). I came across this link http://www.microsoft.com/downloads/details.aspx?familyid=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en 回答1: According to this... SqlHelper was actually replaced with an abstract class,