zoukankan      html  css  js  c++  java
  • 5_添加购物车 D

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

    }
    }

  • 相关阅读:
    第十一周作业
    第十周作业
    第九周编程
    第十二周作业
    第十一周作业
    第十周作业
    第八周作业
    第七周作业
    第五周作业
    2019春季学期第四周作业
  • 原文地址:https://www.cnblogs.com/hianb/p/10145532.html
Copyright © 2011-2022 走看看