using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Text;
using System.Collections.Generic;
using System.Data.SqlClient; namespace MDCRM.DAL
{
/// <summary>
/// 数据访问基类
/// </summary>
public abstract class BaseProvider
{ protected string ConnectionString { get; set; } protected BaseProvider()
{
this.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
} /// <summary>
/// 构造
/// </summary>
/// <param name="connectionStringSectionName">链接字符串节点对应名称</param>
protected BaseProvider(string connectionStringSectionName)
{
this.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringSectionName].ConnectionString;
} /// <summary>
/// 执行 ExecuteNonQuery
/// </summary>
protected int ExecuteNonQuery(DbCommand cmd)
{
foreach (DbParameter param in cmd.Parameters)
{
if (param.Direction == ParameterDirection.Output || param.Direction == ParameterDirection.ReturnValue)
{
switch (param.DbType)
{
case DbType.AnsiString:
case DbType.AnsiStringFixedLength:
case DbType.String:
case DbType.StringFixedLength:
case DbType.Xml:
param.Value = string.Empty;
break;
case DbType.Boolean:
param.Value = false;
break;
case DbType.Byte:
param.Value = byte.MinValue;
break;
case DbType.Date:
case DbType.DateTime:
param.Value = DateTime.MinValue;
break;
case DbType.Currency:
case DbType.Decimal:
param.Value = decimal.MinValue;
break;
case DbType.Guid:
param.Value = Guid.Empty;
break;
case DbType.Double:
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
param.Value = 0;
break;
default:
param.Value = null;
break;
}
}
} FilterSqlParameter(cmd); return cmd.ExecuteNonQuery();
} /// <summary>
/// 执行 ExecuteReader
/// </summary>
protected IDataReader ExecuteReader(DbCommand cmd)
{
FilterSqlParameter(cmd); return ExecuteReader(cmd, CommandBehavior.Default);
} /// <summary>
/// 执行 ExecuteReader
/// </summary>
protected IDataReader ExecuteReader(DbCommand cmd, CommandBehavior behavior)
{
FilterSqlParameter(cmd); return cmd.ExecuteReader(behavior);
} /// <summary>
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。所有其他的列和行将被忽略。
/// </summary>
protected object ExecuteScalar(DbCommand cmd)
{
FilterSqlParameter(cmd); return cmd.ExecuteScalar();
} /// <summary>
/// 执行查询,返回数据结果集
/// </summary>
protected void FillDataSet(System.Data.DataSet dataSet, DbCommand cmd, string tableNames)
{
FillDataSet(dataSet, cmd, tableNames.Split('|'));
} /// <summary>
/// 执行查询,返回数据结果集
/// </summary>
protected void FillDataSet(System.Data.DataSet dataSet, DbCommand cmd, string[] tableNames)
{
System.Data.SqlClient.SqlDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)cmd);
cmd.CommandTimeout = 10000; string mapTableName = "Table";
for (int index = 0; index < tableNames.Length; index++)
{
if (tableNames[index] != null && tableNames[index].Length >= 0)
{
dataAdapter.TableMappings.Add(mapTableName, tableNames[index]);
mapTableName = "Table" + (index + 1).ToString();
}
} FilterSqlParameter(cmd); dataAdapter.Fill(dataSet);
} /// <summary>
/// 集合转成搜索条件
/// </summary>
protected string ListToString<T>(List<T> list, char departChar)
{
string listStr = string.Empty;
if (list != null && list.Count > 0)
{
foreach (T tType in list)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departChar.ToString();
}
}
return listStr.Trim(departChar);
} /// <summary>
/// 集合转成搜索条件
/// </summary>
protected string ListToString<T>(List<T> list, string departStr)
{
string listStr = string.Empty;
if (list != null && list.Count > 0)
{
foreach (T tType in list)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departStr.ToString();
}
} if (!string.IsNullOrEmpty(listStr))
listStr = listStr.Remove(listStr.Length - departStr.Length); return listStr;
} /// <summary>
/// 数组转成搜索条件
/// </summary>
protected string ArrayToString<T>(T[] arr, char departChar)
{
string listStr = string.Empty;
if (arr != null && arr.Length > 0)
{
foreach (T tType in arr)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departChar.ToString();
}
}
return listStr.Trim(departChar);
} /// <summary>
/// 过滤注入式特殊符号
/// </summary>
protected SqlParameter[] FilterSqlParameterArray(params SqlParameter[] parameterValues)
{
int paraCount = 0;
paraCount = parameterValues.Length;
SqlParameter[] paraArray = new SqlParameter[paraCount];
for (int i = 0; i < paraCount; i++)
{
SqlParameter parameterValue = parameterValues[i];
if (parameterValue.DbType == DbType.AnsiString || parameterValue.DbType == DbType.String || parameterValue.SqlDbType == SqlDbType.VarChar || parameterValue.SqlDbType == SqlDbType.NVarChar || parameterValue.SqlDbType == SqlDbType.Text)
{
if (parameterValue.Value != null && parameterValue.Value.ToString() != "")
parameterValue.Value = parameterValue.Value.ToString().Replace("'", "''").Replace("--", "");
}
paraArray[i] = parameterValue;
}
return paraArray;
} /// <summary>
/// 过滤注入式特殊符号
/// </summary>
protected void FilterSqlParameter(DbCommand cmd)
{
int paraCount = 0;
paraCount = cmd.Parameters.Count;
SqlParameter[] paraArray = new SqlParameter[paraCount];
for (int i = 0; i < paraCount; i++)
{
SqlParameter parameterValue = (SqlParameter)cmd.Parameters[i];
if (parameterValue.DbType == DbType.AnsiString || parameterValue.DbType == DbType.String || parameterValue.SqlDbType == SqlDbType.VarChar || parameterValue.SqlDbType == SqlDbType.NVarChar || parameterValue.SqlDbType == SqlDbType.Text)
{
if (parameterValue.Value != null && parameterValue.Value.ToString() != "")
parameterValue.Value = parameterValue.Value.ToString().Replace("'", "''").Replace("--", "");
}
paraArray[i] = parameterValue;
} cmd.Parameters.Clear();
cmd.Parameters.AddRange(paraArray);
}
/// <summary>
/// 将传入的参数生成为相应的sql语句
/// </summary>
/// <param name="param">SqlParameter[]</param>
/// <param name="split">split</param>
/// <returns>string</returns>
protected string SqlParameterToSql(SqlParameter[] param, string split)
{
string sql = string.Empty;
if (param == null) return sql;
for (int i = 0; i < param.Length; i++)
{
SqlParameter key = param[i];
if (i > 0)
{
sql += " " + split;
}
sql += string.Format(" {0}=@{1}", key.ParameterName, key.ParameterName);
}
return sql;
}
/// <summary>
/// 执行查询
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="data">DataSet</param>
/// <param name="tableName">string</param>
/// <param name="param">SqlSelectEntity</param>
protected void Select(string ConnectionString, DataSet data, string tableName, SqlSelectEntity param)
{
string select = string.Join(",", param.Select.ToArray());
string where = " 1=1 ";
if (param.Where != null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("select {0} from {1} where {2}", select, param.TableName, where);
if (!string.IsNullOrEmpty(param.Sort)) {
sql += string.Format(" order by {0}", param.Sort);
}
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open(); FillDataSet(data, cmd, tableName);
}
}
/// <summary>
/// 执行更新
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlUpdateEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Update(string ConnectionString, SqlUpdateEntity param)
{
string where = " 1=1 ";
string update = SqlParameterToSql(param.Update,",");
if (param.Where!=null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("update {0} set {1} where {2}", param.TableName, update, where); using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddRange(param.Update);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open(); return ExecuteNonQuery(cmd);
}
}
/// <summary>
/// 执行删除
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlDeleteEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Delete(string ConnectionString, SqlDeleteEntity param)
{
string where = " 1=1 ";
if (param.Where!=null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("delete from {0} where {1}", param.TableName, where); using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open(); return ExecuteNonQuery(cmd);
}
}
/// <summary>
/// 执行插入
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlInsertEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Insert(string ConnectionString, SqlInsertEntity param)
{ List<string> fileds = new List<string>();
List<string> values = new List<string>();
foreach (SqlParameter parameter in param.Insert)
{
fileds.Add(parameter.ParameterName);
values.Add("@" + parameter.ParameterName);
}
string sql = string.Format("insert into {0}({1}) values({2})", param.TableName, string.Join(",", fileds), string.Join(",", values)); using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddRange(param.Insert);
conn.Open(); return ExecuteNonQuery(cmd);
}
}
}
/// <summary>
/// 查询的基类
/// </summary>
public class SqlEntity
{
/// <summary>
/// 数据表名称
/// </summary>
public string TableName { get; set; }
}
/// <summary>
/// Select Class
/// </summary>
public class SqlSelectEntity : SqlEntity
{
/// <summary>
/// 需要查询的字段,查询所有字段传new List<string>(){"*"}
/// </summary>
public List<string> Select { get; set; }
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
/// <summary>
/// 排序字符串 CreateTime Desc
/// </summary>
public string Sort { get; set; } }
/// <summary>
/// Insert Class
/// </summary>
public class SqlInsertEntity : SqlEntity
{
/// <summary>
/// 插入的字段和值 new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Insert { get; set; } }
/// <summary>
/// Update Class
/// </summary>
public class SqlUpdateEntity : SqlEntity
{
/// <summary>
/// 更新的字段和值 new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Update { get; set; }
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
}
/// <summary>
/// Delete Class
/// </summary>
public class SqlDeleteEntity : SqlEntity
{
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
}
}

  

using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Text;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace MDCRM.DAL
{
/// <summary>
/// 数据访问基类
/// </summary>
public abstract class BaseProvider
{

protected string ConnectionString { get; set; }

protected BaseProvider()
{
this.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}

/// <summary>
/// 构造
/// </summary>
/// <param name="connectionStringSectionName">链接字符串节点对应名称</param>
protected BaseProvider(string connectionStringSectionName)
{
this.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringSectionName].ConnectionString;
}

/// <summary>
/// 执行 ExecuteNonQuery
/// </summary>
protected int ExecuteNonQuery(DbCommand cmd)
{
foreach (DbParameter param in cmd.Parameters)
{
if (param.Direction == ParameterDirection.Output || param.Direction == ParameterDirection.ReturnValue)
{
switch (param.DbType)
{
case DbType.AnsiString:
case DbType.AnsiStringFixedLength:
case DbType.String:
case DbType.StringFixedLength:
case DbType.Xml:
param.Value = string.Empty;
break;
case DbType.Boolean:
param.Value = false;
break;
case DbType.Byte:
param.Value = byte.MinValue;
break;
case DbType.Date:
case DbType.DateTime:
param.Value = DateTime.MinValue;
break;
case DbType.Currency:
case DbType.Decimal:
param.Value = decimal.MinValue;
break;
case DbType.Guid:
param.Value = Guid.Empty;
break;
case DbType.Double:
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
param.Value = 0;
break;
default:
param.Value = null;
break;
}
}
}

FilterSqlParameter(cmd);

return cmd.ExecuteNonQuery();
}

/// <summary>
/// 执行 ExecuteReader
/// </summary>
protected IDataReader ExecuteReader(DbCommand cmd)
{
FilterSqlParameter(cmd);

return ExecuteReader(cmd, CommandBehavior.Default);
}

/// <summary>
/// 执行 ExecuteReader
/// </summary>
protected IDataReader ExecuteReader(DbCommand cmd, CommandBehavior behavior)
{
FilterSqlParameter(cmd);

return cmd.ExecuteReader(behavior);
}

/// <summary>
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。所有其他的列和行将被忽略。
/// </summary>
protected object ExecuteScalar(DbCommand cmd)
{
FilterSqlParameter(cmd);

return cmd.ExecuteScalar();
}

/// <summary>
/// 执行查询,返回数据结果集
/// </summary>
protected void FillDataSet(System.Data.DataSet dataSet, DbCommand cmd, string tableNames)
{
FillDataSet(dataSet, cmd, tableNames.Split('|'));
}

/// <summary>
/// 执行查询,返回数据结果集
/// </summary>
protected void FillDataSet(System.Data.DataSet dataSet, DbCommand cmd, string[] tableNames)
{
System.Data.SqlClient.SqlDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)cmd);
cmd.CommandTimeout = 10000;

string mapTableName = "Table";
for (int index = 0; index < tableNames.Length; index++)
{
if (tableNames[index] != null && tableNames[index].Length >= 0)
{
dataAdapter.TableMappings.Add(mapTableName, tableNames[index]);
mapTableName = "Table" + (index + 1).ToString();
}
}

FilterSqlParameter(cmd);

dataAdapter.Fill(dataSet);
}

/// <summary>
/// 集合转成搜索条件
/// </summary>
protected string ListToString<T>(List<T> list, char departChar)
{
string listStr = string.Empty;
if (list != null && list.Count > 0)
{
foreach (T tType in list)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departChar.ToString();
}
}
return listStr.Trim(departChar);
}

/// <summary>
/// 集合转成搜索条件
/// </summary>
protected string ListToString<T>(List<T> list, string departStr)
{
string listStr = string.Empty;
if (list != null && list.Count > 0)
{
foreach (T tType in list)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departStr.ToString();
}
}

if (!string.IsNullOrEmpty(listStr))
listStr = listStr.Remove(listStr.Length - departStr.Length);

return listStr;
}

/// <summary>
/// 数组转成搜索条件
/// </summary>
protected string ArrayToString<T>(T[] arr, char departChar)
{
string listStr = string.Empty;
if (arr != null && arr.Length > 0)
{
foreach (T tType in arr)
{
if (!string.IsNullOrEmpty(tType.ToString().Trim()))
listStr += tType.ToString().Trim() + departChar.ToString();
}
}
return listStr.Trim(departChar);
}

/// <summary>
/// 过滤注入式特殊符号
/// </summary>
protected SqlParameter[] FilterSqlParameterArray(params SqlParameter[] parameterValues)
{
int paraCount = 0;
paraCount = parameterValues.Length;
SqlParameter[] paraArray = new SqlParameter[paraCount];
for (int i = 0; i < paraCount; i++)
{
SqlParameter parameterValue = parameterValues[i];
if (parameterValue.DbType == DbType.AnsiString || parameterValue.DbType == DbType.String || parameterValue.SqlDbType == SqlDbType.VarChar || parameterValue.SqlDbType == SqlDbType.NVarChar || parameterValue.SqlDbType == SqlDbType.Text)
{
if (parameterValue.Value != null && parameterValue.Value.ToString() != "")
parameterValue.Value = parameterValue.Value.ToString().Replace("'", "''").Replace("--", "");
}
paraArray[i] = parameterValue;
}
return paraArray;
}

/// <summary>
/// 过滤注入式特殊符号
/// </summary>
protected void FilterSqlParameter(DbCommand cmd)
{
int paraCount = 0;
paraCount = cmd.Parameters.Count;
SqlParameter[] paraArray = new SqlParameter[paraCount];
for (int i = 0; i < paraCount; i++)
{
SqlParameter parameterValue = (SqlParameter)cmd.Parameters[i];
if (parameterValue.DbType == DbType.AnsiString || parameterValue.DbType == DbType.String || parameterValue.SqlDbType == SqlDbType.VarChar || parameterValue.SqlDbType == SqlDbType.NVarChar || parameterValue.SqlDbType == SqlDbType.Text)
{
if (parameterValue.Value != null && parameterValue.Value.ToString() != "")
parameterValue.Value = parameterValue.Value.ToString().Replace("'", "''").Replace("--", "");
}
paraArray[i] = parameterValue;
}

cmd.Parameters.Clear();
cmd.Parameters.AddRange(paraArray);
}
/// <summary>
/// 将传入的参数生成为相应的sql语句
/// </summary>
/// <param name="param">SqlParameter[]</param>
/// <param name="split">split</param>
/// <returns>string</returns>
protected string SqlParameterToSql(SqlParameter[] param, string split)
{
string sql = string.Empty;
if (param == null) return sql;
for (int i = 0; i < param.Length; i++)
{
SqlParameter key = param[i];
if (i > 0)
{
sql += " " + split;
}
sql += string.Format(" {0}=@{1}", key.ParameterName, key.ParameterName);
}
return sql;
}
/// <summary>
/// 执行查询
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="data">DataSet</param>
/// <param name="tableName">string</param>
/// <param name="param">SqlSelectEntity</param>
protected void Select(string ConnectionString, DataSet data, string tableName, SqlSelectEntity param)
{
string select = string.Join(",", param.Select.ToArray());
string where = " 1=1 ";
if (param.Where != null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("select {0} from {1} where {2}", select, param.TableName, where);
if (!string.IsNullOrEmpty(param.Sort)) {
sql += string.Format(" order by {0}", param.Sort);
}
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open();

FillDataSet(data, cmd, tableName);
}
}
/// <summary>
/// 执行更新
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlUpdateEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Update(string ConnectionString, SqlUpdateEntity param)
{
string where = " 1=1 ";
string update = SqlParameterToSql(param.Update,",");
if (param.Where!=null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("update {0} set {1} where {2}", param.TableName, update, where);

using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddRange(param.Update);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open();

return ExecuteNonQuery(cmd);
}
}
/// <summary>
/// 执行删除
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlDeleteEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Delete(string ConnectionString, SqlDeleteEntity param)
{
string where = " 1=1 ";
if (param.Where!=null)
{
where += "and " + SqlParameterToSql(param.Where, "and");
}
string sql = string.Format("delete from {0} where {1}", param.TableName, where);

using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
if (param.Where != null)
cmd.Parameters.AddRange(param.Where);
conn.Open();

return ExecuteNonQuery(cmd);
}
}
/// <summary>
/// 执行插入
/// </summary>
/// <param name="ConnectionString">ConnectionString</param>
/// <param name="param">SqlInsertEntity</param>
/// <returns>int(受影响的行数)</returns>
protected int Insert(string ConnectionString, SqlInsertEntity param)
{

List<string> fileds = new List<string>();
List<string> values = new List<string>();
foreach (SqlParameter parameter in param.Insert)
{
fileds.Add(parameter.ParameterName);
values.Add("@" + parameter.ParameterName);
}
string sql = string.Format("insert into {0}({1}) values({2})", param.TableName, string.Join(",", fileds), string.Join(",", values));

using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddRange(param.Insert);
conn.Open();

return ExecuteNonQuery(cmd);
}
}
}
/// <summary>
/// 查询的基类
/// </summary>
public class SqlEntity
{
/// <summary>
/// 数据表名称
/// </summary>
public string TableName { get; set; }
}
/// <summary>
/// Select Class
/// </summary>
public class SqlSelectEntity : SqlEntity
{
/// <summary>
/// 需要查询的字段,查询所有字段传new List<string>(){"*"}
/// </summary>
public List<string> Select { get; set; }
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
/// <summary>
/// 排序字符串 CreateTime Desc
/// </summary>
public string Sort { get; set; }

}
/// <summary>
/// Insert Class
/// </summary>
public class SqlInsertEntity : SqlEntity
{
/// <summary>
/// 插入的字段和值 new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Insert { get; set; }

}
/// <summary>
/// Update Class
/// </summary>
public class SqlUpdateEntity : SqlEntity
{
/// <summary>
/// 更新的字段和值 new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Update { get; set; }
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
}
/// <summary>
/// Delete Class
/// </summary>
public class SqlDeleteEntity : SqlEntity
{
/// <summary>
/// 查询条件new SqlParameter[]{ new SqlParameter("Filed",FiledValue) };
/// 不需要@
/// </summary>
public SqlParameter[] Where { get; set; }
}
}

数据访问公共类(BaseProvider)的更多相关文章

  1. 【ASP.NET-中级】SQLHelper数据访问公共类

    ASP.NET开发中的三层开发思想指的是UI层(界面显示层),BLL层(业务逻辑层),DAL层(数据访问层)三层,三层之间通过函数的调用来达到降低耦合,易于系统维护的目的,SQLHelper助手类的主 ...

  2. 基于SqlSugar的开发框架循序渐进介绍(4)-- 在数据访问基类中对GUID主键进行自动赋值处理

    我们在设计数据库表的时候,往往为了方便,主键ID一般采用字符串类型或者GUID类型,这样对于数据库表记录的迁移非常方便,而且有时候可以在处理关联记录的时候,提前对应的ID值.但有时候进行数据记录插入的 ...

  3. 数据访问层的超级基类AbstractBaseDAL

    using System; using System.Collections; using System.Data; using System.Data.Common; using System.Co ...

  4. Spring.NET 中的 ADO.NET 数据访问的示例

    Spring.NET 1.3.1 中提供了一个使用 AdoTemplate 的完整示例,包括使用泛型和使用非泛型技术进行数据访问,这个示例位于下载的压缩包中\Spring.NET-1.3.1\Spri ...

  5. JS设计模式(三) 数据访问对象模式

    引言 HTML5 提供了两种在客户端存储数据的新方法:localStorage.sessionStorage,他们是Web Storage API 提供的两种存储机制,区别在于前者属于永久性存储,而后 ...

  6. [转]DbHelper通用数据库访问帮助类

    之前我一直都是在博客园中查看各位高手的博文,确实学到了不少知识,不过比较少写博客,现在就把我自己在项目实施过程中使用到比较好的技术框架写出来,希望能让更多的人了解和学习. 通常我们在开发使用数据库访问 ...

  7. Util应用程序框架公共操作类(一):数据类型转换公共操作类(介绍篇)

    本系列文章将介绍一些对初学者有帮助的辅助类,这些辅助类本身并没有什么稀奇之处,如何能发现需要封装它们可能更加重要,所谓授之以鱼不如授之以渔,掌握封装公共操作类的技巧才是关键,我会详细说明创建这些类的动 ...

  8. Util应用程序框架公共操作类(三):数据类型转换公共操作类(扩展篇)

    上一篇以TDD方式介绍了数据类型转换公共操作类的开发,并提供了单元测试和实现代码,本文将演示通过扩展方法来增强公共操作类,以便调用时更加简化. 下面以字符串转换为List<Guid>为例进 ...

  9. Util应用程序框架公共操作类(二):数据类型转换公共操作类(源码篇)

    上一篇介绍了数据类型转换的一些情况,可以看出,如果不进行封装,有可能导致比较混乱的代码.本文通过TDD方式把数据类型转换公共操作类开发出来,并提供源码下载. 我们在 应用程序框架实战十一:创建VS解决 ...

随机推荐

  1. c中结构体的4种定义

    1.常规的标准方式: 1 #include <stdio.h>  2   3 struct student{  4     int age;  5     float score;  6 ...

  2. Linux学习总结—缺页中断和交换技术【转】

    三.Linux缺页中断处理 转自:http://blog.csdn.net/cxylaf/article/details/1626534 1.请求调页中断: 进程线性地址空间里的页面不必常驻内存,例如 ...

  3. [置顶] Linux 虚拟地址与物理地址的映射关系分析【转】

    转自:http://blog.csdn.net/ordeder/article/details/41630945 版权声明:本文为博主(http://blog.csdn.net/ordeder)原创文 ...

  4. Object和Thread自带的原生方法

    Object类: 1) clone():创建并返回此对象的一个副本. 2) equals(obj):指示其对象是否与此对象“相等”. 3) finalize():当垃圾回收器确定不存在对该对象的更多引 ...

  5. python的tips:字符和字符串的问题

    今天,自己建立了一个redis,python去访问的时候, 设置可以key以后,再读取key,返回的是字符, 和字符串比较,需要做一个转换, 信息如下: import redisr=redis.Red ...

  6. Nginx虚拟主机(Virtual Host)配置

    虚拟主机(Virtual Host)可以在一台服务器上绑定多个域名,架设多个不同的网站,一般在开发机或者要部署多个小网站的服务器上需要配置虚拟主机.nginx的虚拟主机配置其实也挺简单,为了使得配置文 ...

  7. SQL Server 预编译执行SQLs

    问题描述: MVC5项目,利用执行sql的方式获取数据,但是在利用预编译执行的时候报错了,字段XXXwhich was not supplied. 其实就是这个参数传了个null导致的.在传参数之前做 ...

  8. HDU 1203 【01背包/小数/概率DP】

    I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  9. 2017 China Collegiate Programming Contest Final (CCPC 2017)

    题解右转队伍wiki https://acm.ecnu.edu.cn/wiki/index.php?title=2017_China_Collegiate_Programming_Contest_Fi ...

  10. 六. 异常处理4.try和catch的使用

    尽管由Java运行时系统提供的默认异常处理程序对于调试是很有用的,但通常你希望自己处理异常.这样做有两个好处.第一,它允许你修正错误.第二,它防止程序自动终止.大多数用户对于在程序终止运行和在无论何时 ...