DBHelper 可以这么简洁的写代码了

var result = new List<MyDataType>();
using (var conn = SqlHelper.OpenConnection())
{
    var cmd = SqlHelper.GetCommand(conn, "select * from [table] where depart='技术部' and name<>@name");
    SqlHelper.SetParameter(cmd, "name", "张三");
    result = (from IDataRecord rd in cmd.ExecuteReader()
                select new DataType
                {
                    Name = (string)rd["Name"],
                    Cost = (decimal)rd["Cost"]
                }).ToList();
}

你可能感兴趣的:(DBHelper 可以这么简洁的写代码了)