Author: maomao
Created:Description:--%>
usingSystem;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespace {public static partial class DAL
{public static List<> Search(string sqlStr,Listpms)
{
List<> list = new List<>();
DataTable table=SqlHelper.ExecuteDataTable(sqlStr,pms.ToArray());foreach (DataRow dr intable.Rows)
{ model = new (dr);
list.Add(model);
}returnlist;
}public static bool Insert(model)
{string sqlStr = "";
List fileds = new List();
List pFileds = new List();
List pms = new List();#region 添加参数
{%>
if(model.!=null&&model.!=newDateTime())
{
fileds.Add("[]");
pFileds.Add("@");
pms.Add(new SqlParameter("",SqlDbType.,){Value=model.});
}
if(model.!=null)
{
fileds.Add("[]");
pFileds.Add("@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
}{
fileds.Add("[]");
pFileds.Add("@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
}
#endregionStringBuilder sb= newStringBuilder();
sb.Append("INSERT INTO (");
sb.Append(string.Join(",", fileds));
sb.Append(") values (");
sb.Append(string.Join(",", pFileds));
sb.Append(")");
sqlStr=sb.ToString();int i=SqlHelper.ExecuteNonQuery(sqlStr, pms.ToArray());return i>0;
}public static bool Update(model)
{string sqlStr = "";
List fileds = new List();
List pFileds = new List();
List pms = new List();#region 添加参数
pFileds.Add("[]=@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
if(model.!=null&&model.!=newDateTime())
{
fileds.Add("[]=@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
}
if(model.!=null)
{
fileds.Add("[]=@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
}fileds.Add("[]=@");
pms.Add(new SqlParameter("", SqlDbType.,){Value=model.});
#endregionStringBuilder sb= newStringBuilder();
sb.Append("update set");
sb.Append(string.Join(",", fileds));
sb.Append("where");
sb.Append(string.Join("and", pFileds));
sqlStr=sb.ToString();int i=SqlHelper.ExecuteNonQuery(sqlStr, pms.ToArray());return i>0;
}
}
}
public string Convert2Pascal(stringname)
{
StringBuilder sb= newStringBuilder();string[] strs = name.Split(new char[] { '_'});foreach (string str instrs)
{
sb.Append(str.Substring(0,1).ToUpper());
sb.Append(str.Substring(1));
}returnsb.ToString();
}public stringConvertTablename2Pascal(TableSchema table)
{
StringBuilder sb= newStringBuilder();string[] strs = table.Name.Split(new char[] { '_'});int index=0;foreach (string str instrs)
{if(index==0)
{
index++;continue;
}
sb.Append(str.Substring(0,1).ToUpper());
sb.Append(str.Substring(1));
}returnsb.ToString();
}