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();
}
}
}
}