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

    }
    }

  • 相关阅读:
    流程控制之while循环
    流程控制之if...else
    基本运算符
    基本数据类型
    注释
    用户交互
    常量
    test
    查询方法
    删除代码
  • 原文地址:https://www.cnblogs.com/hianb/p/10145532.html
Copyright © 2011-2022 走看看