一,概述:

这个DataHelper 类是基于我上个博客里发的SQLDataAccess 这个类做的一个简单的封装,为了结合自己的实体类和数据操作而产生的。

这里面用了  属性类,反射。还有 数据类型的方法扩展。(入门的同学可以看看。)

这里面有几个地方要注意下,一个是 GetEntity<T> 方法里的 ModelDataAttribute 对象,是我自己写的一个实体属性类。

还有 connString.IsNullOrEmpty() 这个是我封装的一个Stirng 的扩展类(StringExtensions)里的方法。这两个类在下面可以找到。

这个DataHelper类,必须基于 SQLDataAccess 和我自己定义的实体类的形式才可以实现。 这里大家只是借鉴下就好了.

yeqw.FrameWork;  我把 ModelDataAttribute StringExtensions 封装到里面了。

二:代码:

DataHelper:(这里写的不是太好,其中的分页只是调用一个分页存储过程。这个Helper里最大的一个问题,就是不支持事务,一直没考虑好怎么把事务封进来)

 namespace yeqw.DataHelper
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using yeqw.FrameWork;
using yeqw.sql.common.DB; public class DBHelper
{
public static int DbExecuteNonQuery(SqlCommand Command)
{
using (SQLDataAccess access = new SQLDataAccess())
{
return access.ExecuteNonQuery(Command);
}
} public static int DbExecuteNonQuery(SqlCommand Command, string connString)
{
using (SQLDataAccess access = new SQLDataAccess(connString))
{
return access.ExecuteNonQuery(Command);
}
} public static object DbExecuteScalar(SqlCommand Command)
{
SQLDataAccess access = new SQLDataAccess();
return access.ExecuteScalar(Command);
} public static DataTable ExecProc_sp_GetPage(string tbName, string colName, int coltype, string orderby, string collist, int pagesize, int page, string condition, out int pages, out int rsCount, out int curCount)
{
return ExecProc_sp_GetPage(tbName, colName, coltype, orderby, collist, pagesize, page, condition, out pages, out rsCount, out curCount, "");
} public static DataTable ExecProc_sp_GetPage(string tbName, string colName, int coltype, string orderby, string collist, int pagesize, int page, string condition, out int pages, out int rsCount, out int curCount, string connstring)
{
SQLDataAccess access = null;
DataTable table;
if (connstring.IsNullOrEmpty())
{
access = new SQLDataAccess();
}
else
{
access = new SQLDataAccess(connstring);
}
try
{
SqlCommand command = GetCommand(tbName, colName, coltype, orderby, collist, pagesize, page, condition);
DataSet ds = new DataSet();
access.FillDataSet(command, ds);
pages = (int)command.Parameters["@pages"].Value;
rsCount = (int)command.Parameters["@rsCount"].Value;
curCount = (int)command.Parameters["@curCount"].Value;
table = ds.Tables[];
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
finally
{
access.Dispose();
}
return table;
} public static List<T> FillData<T>(SqlCommand Command) where T : class, new()
{
return FillData<T>(Command, string.Empty);
} public static List<T> FillData<T>(SqlCommand Command, string connString) where T : class, new()
{
List<T> list = new List<T>();
SQLDataAccess access = null;
if (connString.IsNullOrEmpty())
{
access = new SQLDataAccess();
}
else
{
access = new SQLDataAccess(connString);
}
try
{
SqlDataReader reader = access.ExecuteReader(Command);
while (reader.Read())
{
T entity = Activator.CreateInstance<T>();
list.Add(GetEntity<T>(reader, entity));
}
if (!reader.IsClosed)
{
reader.Close();
}
}
finally
{
access.Dispose();
}
return list;
} public static T FillObject<T>(SqlCommand Command) where T : class, new()
{
return FillObject<T>(Command, string.Empty);
} public static T FillObject<T>(SqlCommand Command, string connString) where T : class, new()
{
SQLDataAccess access = null;
if (connString.IsNullOrEmpty())
{
access = new SQLDataAccess();
}
else
{
access = new SQLDataAccess(connString);
}
SqlDataReader reader = null;
try
{
reader = access.ExecuteReader(Command);
if (reader.Read())
{
return GetEntity<T>(reader, Activator.CreateInstance<T>());
}
}
finally
{
if (!reader.IsClosed)
{
reader.Close();
}
access.Dispose();
}
return default(T);
} private static SqlCommand GetCommand(string tbName, string colName, int coltype, string orderby, string collist, int pagesize, int page, string condition)
{
string cmdText = "sp_GetPage";
SqlCommand command = new SqlCommand(cmdText)
{
CommandTimeout = ,
CommandType = CommandType.StoredProcedure
};
command.Parameters.Add("@tbName", SqlDbType.VarChar, );
command.Parameters["@tbName"].Value = tbName;
command.Parameters.Add("@colName", SqlDbType.VarChar, );
command.Parameters["@colName"].Value = colName;
command.Parameters.Add("@coltype", SqlDbType.Int, );
command.Parameters["@coltype"].Value = coltype;
command.Parameters.Add("@orderby", SqlDbType.VarChar, );
command.Parameters["@orderby"].Value = orderby;
command.Parameters.Add("@collist", SqlDbType.VarChar, );
command.Parameters["@collist"].Value = collist;
command.Parameters.Add("@pagesize", SqlDbType.Int, );
command.Parameters["@pagesize"].Value = pagesize;
command.Parameters.Add("@page", SqlDbType.Int, );
command.Parameters["@page"].Value = page;
command.Parameters.Add("@condition", SqlDbType.VarChar, 0x7d0);
command.Parameters["@condition"].Value = condition;
command.Parameters.Add("@pages", SqlDbType.Int);
command.Parameters.Add("@rsCount", SqlDbType.Int);
command.Parameters.Add("@curCount", SqlDbType.Int);
command.Parameters["@pages"].Direction = ParameterDirection.Output;
command.Parameters["@rsCount"].Direction = ParameterDirection.Output;
command.Parameters["@curCount"].Direction = ParameterDirection.Output;
return command;
} public static DataSet GetDataSet(SqlCommand Command)
{
SQLDataAccess access = new SQLDataAccess();
DataSet ds = new DataSet();
try
{
access.FillDataSet(Command, ds);
}
finally
{
access.Dispose();
}
return ds;
} public static DataTable GetDataTable(SqlCommand Command)
{
SQLDataAccess access = new SQLDataAccess();
DataTable table = null;
try
{
table = new DataTable();
table = access.FillDataSet(Command);
}
finally
{
access.Dispose();
}
return table;
} public static DataTable GetDataTable(SqlCommand Command, string connString)
{
SQLDataAccess access = new SQLDataAccess(connString);
DataTable table = null;
try
{
table = new DataTable();
table = access.FillDataSet(Command);
}
finally
{
access.Dispose();
}
return table;
} public static DataTable GetDataTableSchema(string TableName)
{
string cmdText = string.Format("select * from {0} where 1=2", TableName);
SQLDataAccess access = new SQLDataAccess();
DataTable table = null;
try
{
SqlCommand command = new SqlCommand(cmdText);
table = new DataTable();
table = access.FillDataSet(command);
}
finally
{
access.Dispose();
}
return table;
} public static DateTime GetDate()
{
DateTime now = DateTime.Now;
string sql = "SELECT getdate()";
using (SQLDataAccess access = new SQLDataAccess())
{
SqlDataReader reader = access.ExecuteReader(sql);
if (reader.Read())
{
now = (DateTime)reader[];
}
if (!reader.IsClosed)
{
reader.Close();
}
}
return now;
} public static T GetEntity<T>(IDataReader reader, T entity)
{
PropertyInfo[] properties = entity.GetType().GetProperties();
foreach (PropertyInfo info in properties)
{
object[] customAttributes = info.GetCustomAttributes(true);
if (customAttributes.Length != )
{
ModelDataAttribute attribute = (ModelDataAttribute)customAttributes[];
if (!(reader[attribute.SQLFieldName] is DBNull))
{
info.SetValue(entity, reader[attribute.SQLFieldName], null);
}
}
}
return entity;
} public static SqlParameter GetSqlParamseter(string parameterName, object Value)
{
return GetSqlParamseter(parameterName, SqlDbType.NVarChar, , Value);
} public static SqlParameter GetSqlParamseter(string parameterName, SqlDbType dbType, int size, ParameterDirection Direction)
{
SqlParameter parameter = new SqlParameter
{
ParameterName = parameterName,
SqlDbType = dbType,
Direction = Direction
};
if (size != )
{
parameter.Size = size;
}
return parameter;
} public static SqlParameter GetSqlParamseter(string parameterName, SqlDbType dbType, int size, object Value)
{
SqlParameter parameter = new SqlParameter
{
ParameterName = parameterName,
SqlDbType = dbType
};
if (((Value == null) || string.IsNullOrEmpty(Value.ToString())) || ((parameter.SqlDbType == SqlDbType.DateTime) && (DateTime.MinValue == Convert.ToDateTime(Value))))
{
parameter.Value = DBNull.Value;
}
else
{
parameter.Value = Value;
}
if (size != )
{
parameter.Size = size;
}
return parameter;
} public static void SetDBCommandParameters(SqlCommand Comm, object entity)
{
Comm.Parameters.RemoveAt();
if (Comm.Parameters.Count > )
{
PropertyInfo[] properties = entity.GetType().GetProperties();
foreach (SqlParameter parameter in Comm.Parameters)
{
bool flag = false;
foreach (PropertyInfo info in properties)
{
object[] customAttributes = info.GetCustomAttributes(typeof(ModelDataAttribute), true);
if (customAttributes.Length != )
{
ModelDataAttribute attribute = (ModelDataAttribute)customAttributes[];
if (string.Equals(attribute.SQLFieldName, parameter.ParameterName.Replace("@", ""), StringComparison.CurrentCultureIgnoreCase))
{
object obj2 = info.GetValue(entity, null);
parameter.SqlDbType = attribute.SQLDbType;
parameter.Size = attribute.SQLSize;
parameter.Direction = attribute.SQLParameterDirection;
if (obj2 != null)
{
parameter.Value = obj2;
}
else
{
parameter.Value = DBNull.Value;
}
flag = true;
break;
}
}
}
if (!flag)
{
throw new Exception("没有找到参数值!");
}
}
}
} public static void SetSqlParameters(SqlCommand comm, object entity)
{
comm.Parameters.Clear();
string commandText = comm.CommandText;
PropertyInfo[] properties = entity.GetType().GetProperties();
foreach (PropertyInfo info in properties)
{
object[] customAttributes = info.GetCustomAttributes(typeof(ModelDataAttribute), true);
if (customAttributes.Length >= )
{
ModelDataAttribute attribute = customAttributes[] as ModelDataAttribute;
if (Regex.IsMatch(commandText, "@" + attribute.SQLFieldName + @"\b", RegexOptions.Singleline | RegexOptions.IgnoreCase))
{
object obj2 = info.GetValue(entity, null);
SqlParameter parameter = comm.CreateParameter();
parameter.SqlDbType = attribute.SQLDbType;
parameter.ParameterName = "@" + attribute.SQLFieldName;
parameter.Size = attribute.SQLSize;
parameter.Direction = attribute.SQLParameterDirection;
parameter.Value = (obj2 == null) ? DBNull.Value : obj2;
comm.Parameters.Add(parameter);
}
}
}
} public static int UpdateDataTable(string TableName, DataTable dataTable)
{
SQLDataAccess access = new SQLDataAccess();
SqlCommand selectCommand = new SqlCommand(string.Format("select * from {0} where 1=2", TableName));
return access.UpdateDataTable(selectCommand, dataTable);
}
}
}

实体类:

 using System;
using System.Data;
using yeqw.FrameWork;
using System.ComponentModel; namespace yeqw.bm.Model
{
/// <summary>
/// Summary description for adminmenuinfo
/// </summary>
[Serializable]
public class AdminMenuInfo
{
/// <summary>
/// 流水号
/// </summary>
[ModelData("ID", SqlDbType.Int, , ParameterDirection.InputOutput)]
public int ID
{
set;
get;
}
/// <summary>
/// 用户流水号
/// </summary>
[ModelData("AdminID", SqlDbType.Int, )]
public int AdminID
{
set;
get;
}
/// <summary>
/// 菜单权限流水号
/// </summary>
[ModelData("MenuAuthorityID", SqlDbType.Int, )]
public int MenuAuthorityID
{
set;
get;
} /// <summary>
/// 操作员流水号
/// </summary>
[ModelData("OperAdminID", SqlDbType.Int, )]
public int OperAdminID
{
set;
get;
} /// <summary>
/// 操作时间
/// </summary>
[ModelData("OperTime", SqlDbType.DateTime, )]
public DateTime OperTime
{
set;
get;
} /// <summary>
/// 角色菜单权限状态(0 冻结 1 正常,2关闭)
/// </summary>
[ModelData("Status", SqlDbType.TinyInt, )]
public byte Status
{
set;
get;
}
/// <summary>
/// 入库时间
/// </summary>
[ModelData("InsertTime", SqlDbType.DateTime, )]
public DateTime InsertTime
{
set;
get;
}
}
}

实体类

StringExtensions 类:

namespace yeqw.FrameWork
{
using System;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization; public static class StringExtensions
{
public static bool CheckSqlCondition(this string input)
{
return true;
} public static object Deserialize(this string base64Str)
{
return SerializeHelper.Deserialize(base64Str);
} public static string FormatExtension(this string input, params object[] args)
{
return string.Format(input, args);
} public static bool IsALLInteger(this string input)
{
return Regex.IsMatch(input, @"^([-]\d+)|\d+$");
} public static bool IsAZaz09(this string input)
{
return Regex.IsMatch(input, "^[A-Za-z0-9]+$");
} public static bool IsByte(this string input)
{
byte num;
return byte.TryParse(input, out num);
} public static bool IsChinese(this string input)
{
return Regex.IsMatch(input, "^([一-龥]|[︰-ᅠ])+$");
} public static bool IsDecimal(this string input)
{
decimal num;
return decimal.TryParse(input, out num);
} public static bool IsEmail(this string input)
{
return Regex.IsMatch(input, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
} public static bool IsEnglish(this string input)
{
return Regex.IsMatch(input, "^[a-zA-Z]+$");
} public static bool IsIdCard(this string input)
{
string str;
string str2;
string str3 = "10x98765432";
int[] numArray = new int[] {
, , , , , , , , , , , , , , , , };
string[] strArray = new string[] {
"", "", "", "", "", "", "", "", "", "", "", "北京", "天津", "河北", "山西", "内蒙古",
"", "", "", "", "", "辽宁", "吉林", "黑龙江", "", "", "", "", "", "", "", "上海",
"江苏", "浙江", "安微", "福建", "江西", "山东", "", "", "", "河南", "湖北", "湖南", "广东", "广西", "海南", "",
"", "", "重庆", "四川", "贵州", "云南", "西藏", "", "", "", "", "", "", "陕西", "甘肃", "青海",
"宁夏", "新疆", "", "", "", "", "", "台湾", "", "", "", "", "", "", "", "",
"", "香港", "澳门", "", "", "", "", "", "", "", "", "国外"
};
Match match = Regex.Match(input, @"^(\d{2})\d{4}(((\d{2})(\d{2})(\d{2})(\d{3}))|((\d{4})(\d{2})(\d{2})(\d{3}[xX\d])))$");
if (match.Length == )
{
return false;
}
if ((int.Parse(match.Result("$1")) >= strArray.Length) || (strArray[int.Parse(match.Result("$1"))] == ""))
{
return false;
}
if (match.Result("$2").Length == )
{
str2 = input.Substring(, 0x11);
str = string.Format("{0}-{1}-{2}", match.Result("$9"), match.Result("$10"), match.Result("$11"));
}
else
{
str2 = input.Substring(, ) + "" + input.Substring();
str = string.Format("19{0}-{1}-{2}", match.Result("$4"), match.Result("$5"), match.Result("$6"));
}
try
{
DateTime.Parse(str);
}
catch (Exception)
{
return false;
}
int num = ;
for (int i = ; i <= 0x10; i++)
{
num += int.Parse(str2.Substring(i, )) * numArray[i];
}
str2 = str2 + str3.Substring(num % , );
return ((input.Length == ) || ((input.Length == 0x12) && (input == str2)));
} public static bool IsInteger(this string input)
{
return Regex.IsMatch(input, "^[0-9]+$");
} public static bool IsIP(this string input)
{
return Regex.IsMatch(input, @"^(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])$");
} public static bool IsNullOrEmpty(this string input)
{
return string.IsNullOrEmpty(input);
} public static bool IsPhone(this string input)
{
return Regex.IsMatch(input, @"^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$");
} public static bool IsUrl(this string input)
{
return Regex.IsMatch(input, "^http:\\/\\/[A-Za-z0-9\\./=\\?%\\-&_~`@[\\]\\':+!]+([^<>\"])+$");
} public static string NoHTML(this string Htmlstring)
{
Htmlstring = Regex.Replace(Htmlstring, "<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "<(.[^>]*)>", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "-->", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "<!--.*", "", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(quot|#34);", "\"", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(amp|#38);", "&", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(lt|#60);", "<", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(gt|#62);", ">", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(iexcl|#161);", "\x00a1", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(cent|#162);", "\x00a2", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(pound|#163);", "\x00a3", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, "&(copy|#169);", "\x00a9", RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
Htmlstring = Htmlstring.Replace("<", "");
Htmlstring = Htmlstring.Replace(">", "");
Htmlstring = Htmlstring.Replace("\r\n", "");
Htmlstring = Htmlstring.Replace("&hellip;", "");
Htmlstring = Htmlstring.Replace("&mdash;", "");
Htmlstring = Htmlstring.Replace("&rdquo;", "");
Htmlstring = Htmlstring.Replace("&ldquo;", "");
return Htmlstring;
} public static string SubStringCN(this string stringToSub, int length, string flage)
{
if (stringToSub.IsNullOrEmpty())
{
return string.Empty;
}
Regex regex = new Regex("[一-龥]+", RegexOptions.Compiled);
char[] chArray = stringToSub.ToCharArray();
int byteCount = Encoding.Default.GetByteCount(stringToSub);
StringBuilder builder = new StringBuilder();
string str = string.Empty;
int num2 = ;
for (int i = ; i < byteCount; i++)
{
if (i >= chArray.Length)
{
return str;
}
if (regex.IsMatch(chArray[i].ToString()))
{
num2 += ;
}
else
{
num2++;
}
builder.Append(chArray[i]);
if (num2 > length)
{
return (builder.ToString(, builder.ToString().Length - ) + flage);
}
str = builder.ToString();
}
return str;
} public static int ToByte(this string input)
{
return byte.Parse(input);
} public static decimal ToDecimal(this string input)
{
return decimal.Parse(input);
} public static long ToInt64(this string input)
{
return long.Parse(input);
} public static int ToInteger(this string input)
{
return int.Parse(input);
} public static T ToObject<T>(this string input) where T: class, new()
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Deserialize<T>(input);
} public static bool Validate(this string input, string parrtern)
{
return Regex.IsMatch(input, parrtern);
}
}
}

ModelDataAttribute 类:

namespace yeqw.FrameWork
{
using System;
using System.Data;
using System.Runtime.CompilerServices; [AttributeUsage(AttributeTargets.Property, Inherited=true)]
public class ModelDataAttribute : Attribute
{
public ModelDataAttribute(string sqlFieldName, SqlDbType sqlParameterType) : this(sqlFieldName, sqlParameterType, )
{
} public ModelDataAttribute(string sqlFieldName, SqlDbType sqlParameterType, int sqlparametersize) : this(sqlFieldName, sqlParameterType, sqlparametersize, ParameterDirection.Input)
{
} public ModelDataAttribute(string sqlFieldName, SqlDbType sqlParameterType, int sqlparametersize, ParameterDirection sqlParameterDirection)
{
this.SQLFieldName = sqlFieldName;
this.SQLDbType = sqlParameterType;
this.SQLSize = sqlparametersize;
this.SQLParameterDirection = sqlParameterDirection;
} public void Validate(object value)
{
if (!this.CanNull && string.IsNullOrEmpty(value.ToString()))
{
throw new ArgumentException(this.Message);
}
} public bool CanNull { get; set; } public string Message { get; set; } public SqlDbType SQLDbType { get; set; } public string SQLFieldName { get; set; } public ParameterDirection SQLParameterDirection { get; set; } public int SQLSize { get; set; } public enum EnumValidateType : byte
{
IsMaxLength = ,
IsNull = ,
IsNumber =
}
}
}

三:总结:

  DataHepler 和SQLDataAccess 这两个类都是比较简单的一个类库设计。做任何项目适合自己的才是最好的。用CodeSmith 这样的工具都能生成很好的只要的类库。

但我希望大家尤其是刚入门的童鞋要明白,基础才是一切的根本。知其然更要致其所以然。在编程的路上遇到不同的级别的项目,尤其现在都说的大数据时代。任何的类库

都是有自己的局限性的。只有因地制宜,根据实际需要做出自己最合理的选择才是王道。不仅要举一翻三,更要一通百通。类库是死的人是活的,不管是什么样的技术,明白

基础了,才是最重要的。(自己的一点感慨,瞎喷的。呵呵)

================================================================= 
HI,如果童鞋们觉得本人此博文对你有用,请不要吝啬自己的鼠标,给此博文一个“推荐”吧。鼓励,鼓励。哈哈 

本博文系博主原创,版权归博主所有,如需转载,请注明转载地址。

当前博客原始地址:yeqw1985.cnblogs.com 

=================================================================

新浪微博 http://www.weibo.com/yeqw  热烈欢迎大家一起交流讨论并提出宝贵意见,多多指导。

分享下自己一直用的.NET SQLSERVER 封装类下自己写的DataHelper 操作类的更多相关文章

  1. 分享今天在客户那里遇到的SQLSERVER连接超时以及我的解决办法

    分享今天在客户那里遇到的SQLSERVER连接超时以及我的解决办法 客户的环境:SQLSERVER2005,WINDOWS2003 SP2  32位 这次发生连接超时的时间是2013-8-5  21: ...

  2. 无法序列化会话状态。在“StateServer”或“SQLServer”模式下,ASP.NET 将序列化会话状态对象,因此不允许使用无法序列化的对象或 MarshalByRef 对象。如果自定义会话状态存储在“Custom”模式下执行了类似的序列化,则适用同样的限制。

    将项目部署到服务器后发现有如下问题,查了网上好多说是需要被序列化的类没有写上[Serializable]标志,所以把全部需要序列化的列都写上了标志发现还是不是,最后查到了发现网上说的并不太准确,而是需 ...

  3. 关于:“无法序列化会话状态。在“StateServer”或“SQLServer”模式下,...的问题

    关于:“无法序列化会话状态.在“StateServer”或“SQLServer”模式下,...的问题 错误描述: 无法序列化会话状态.在“StateServer”或“SQLServer”模式下,ASP ...

  4. 【无私分享:ASP.NET CORE 项目实战(第七章)】文件操作 FileHelper

    目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在程序设计中,我们很多情况下,会用到对文件的操作,在 上一个系列 中,我们有很多文件基本操作的示例,在Core中有一些改变,主 ...

  5. 用脚本如何实现将Linux下的txt文件批量转化为Windows下的txt文件?

    众所周知,Windows和Linux的文件换行回车格式不同,Windows下换行格式是\r\n(回车+换行),Linux下换行格式为\n(只是换行),因此,其中一个操作系统的文本文件若需要在另外一个中 ...

  6. window下上传文件至linux(windows下如何访问linux)

    ========相信我,按照步骤来一定能成功====== 我将从三个方面来说明:为什么要搭建访问服务器.如何搭建访问服务器.windows如下访问 为什么要搭建访问Linux服务器 我们都知道,服务器 ...

  7. SQLServer 常见SQL笔试题之语句操作题详解

    SqlServer 常见SQL笔试题之语句操作题详解 by:授客 QQ:1033553122 测试数据库 CREATE DATABASE handWriting ON PRIMARY ( name = ...

  8. 怎么将linux下的项目转换成windows的VS2010下的项目?

    怎么将linux下的项目转换成windows的VS2010下的项目?             不显示删除回复             显示所有回复             显示星级回复        ...

  9. 100怎么变成100.00 || undefined在数字环境下是:NaN || null在数字环境下是0 || 数组的toString()方法把每个元素变成字符串,拼在一起以逗号隔开 || 空数组转换成字符串后是什么?

    100怎么变成100.00?

随机推荐

  1. JS实现Promise原理

    promise是用来解决Js中的异步问题的,js中所有的异步可从callback → promise → generator + co = async + await 其实所有的都是callback的 ...

  2. Ajax跨域请求以及乱码解决

    Ajax跨域请求2种解决方法 1 ) 什么叫跨域请求,协议,域名,端口号,其中一样不同都称跨域; 第一种:使用script标签发送请求; //创建一个script标签; var v_element=d ...

  3. Servlet学习笔记03——什么是DAO?

    1.案例 (1)添加用户 step1.建表 create table t_user( id int primary key auto_increment, username varchar(50) u ...

  4. mysql 1055 的错误

    1.Err1055,出现这个问题往往是在执行sql语句时候,在最后一行会出现这个问题. [Err] 1055 - Expression #1 of ORDER BY clause is not in ...

  5. Centos7上搭建activemq集群和zookeeper集群

    Zookeeper集群的搭建 1.环境准备 Zookeeper版本:3.4.10. 三台服务器: IP 端口 通信端口 10.233.17.6 2181 2888,3888 10.233.17.7 2 ...

  6. Java NIO 教程

    Java NIO(New IO)是从Java 1.4版本开始引入的一个新的IO API,可以替代标准的Java IO API.本系列教程将有助于你学习和理解Java NIO. Java NIO提供了与 ...

  7. 子查询,用户管理,pymysql使用

    当我们的一条记录 分散不同的表中时,就需要进行多表查询例如 一对一 一对多 多对多 1.笛卡尔积查询 意思就是将两个表中的所有数据 全部关联在一起例如A表有两条 B表有三条 一共有6条会产生大量的错误 ...

  8. urllib使用四--urlencode,urlparse,

    urllib.urlencode 把字典数据转换为URL编码 # -*- coding: cp936 -*- import urllib params = {'score':100,'name':'爬 ...

  9. 关于IAR软件的Go to Definition of功能问题的解决方法

    关于IAR软件的Go to Definition of功能问题的解决方法 首先,工程文件必须放在没有中文的路径下,如果路径里有中文应把中文该成英文 如:C:\Users\ABC\Desktop\新建文 ...

  10. Android stadio Switch repository Android stadio切换仓库

    Android stadio 有时候,有很多module. 这些module 都有自己的仓库.也就是不在一块.那么,Android stadio 默认管理的就是根git. 如图,画对号的就是默认的. ...