标签:using item type string DApp .sql dbconnect += log
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MODEL;
using Dapper;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class ZhpDAL<T>
{
//显示+下拉绑定
string constr = "Data Source=.;Initial Catalog=week1;Integrated Security=True";
public List<T> GetList(string TableName)
{
var t = typeof(T);
var ts = t.GetProperties();
string sqlstr = "select ";
foreach (var item in ts)
{
sqlstr += item.Name+",";
}
sqlstr = sqlstr.Substring(0,sqlstr.Length - 1);
sqlstr += " from " + TableName;
using (IDbConnection con=new SqlConnection(constr))
{
return con.Query<T>(sqlstr).ToList();
}
}
}
}
标签:using item type string DApp .sql dbconnect += log
原文地址:https://www.cnblogs.com/hianb/p/10145532.html