Public void Add()
{
 List<PPQuery> lists = GetDataByFile(tempFilePath);
private static readonly string sqlconnection = "Data Source=.;Initial Catalog=xxxx;Persist Security Info=True;User ID=sa;Password=123";
using (var connection = new System.Data.SqlClient.SqlConnection(sqlconnection))
{
resultData = connection.Execute("Insert into [PPQuery] values (@ID,@Name,@Time,@Company)", lists);
}
}
   public List<PPQuery> GetDataByFile(string path)
{
var file = File.Open(path, FileMode.Open);
List<string> txt = new List<string>();
using (var stream = new StreamReader(file, System.Text.Encoding.GetEncoding("utf-8")))
{
while (!stream.EndOfStream)
{
txt.Add(stream.ReadLine());
}
}
file.Close();
List<PPQuery> models = new List<PPQuery>();
//循环list
foreach (string item in txt)
{
string[] tempstr = item.Split(',');
PPQuery model = new PPQuery();
model.ID = tempstr[];
model.Name = tempstr[];
model.Time =Convert.ToDateTime(tempstr[]);
model.Company = tempstr[];
models.Add(model);
}
return models;
}

Dapper批量添加的更多相关文章

  1. zabbix利用api批量添加item,并且批量配置添加graph

    关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个ho ...

  2. 百度地图API 批量添加 带检索功能的信息窗口

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. yii2批量添加的问题

    作者:白狼 出处:http://www.manks.top/yii2_batch_insert.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否 ...

  4. EF批量添加数据性能慢的问题的解决方案

    //EF批量添加数据性能慢的问题的解决方案 public ActionResult BatchAdd() { using (var db = new ToneRoad.CEA.DbContext.Db ...

  5. Java使用Mysql数据库实现批量添加数据

    EmployeeDao.java //批处理添加数据 public int saveEmploeeBatch(){ int row = 0; try{ con = DBCon.getConn(); S ...

  6. Mybatis批量添加对象List

    1.对应的xml文件: <!--批量添加--><insert id="insertStandardItemInfo" parameterType="ha ...

  7. SqlServer——批量操作(批量添加,删除)

    批量添加数据: 一条insert语句批量插入多条记录 常见的insert语句,向数据库中,一条语句只能插入一条数据: insert into persons (id_p, lastname , fir ...

  8. react.js 之 批量添加与删除功能

    最近做的CMS需要用到批量添加图片的功能:在添加文件的容器盒子内,有两个内容,分别是:添加按钮与被添加的选择文件组件. 结构分析: 被添加的组件,我们称为:UploadQiNiuFiles(七牛文件上 ...

  9. SQL批量添加主键脚本

    --SQL批量添加主键脚本 --操作提示:运行此脚本前请记得备份您要操作的数据库 --实现功能:执行脚本后数据库中的所有数据表都会有一个主键 --添加规则1:主键名称为ID(可自己修改),数据类型为整 ...

随机推荐

  1. js中this那些事儿

    前几天写东西由于恶趣味作祟将所有的函数全部封装在json中,起初好好的,函数B也可以调用函数A的内容,不过在写一个点击事件时出现了意外, 代码如下: var $ ={ "A":fu ...

  2. D3.js绘制平行坐标图

    参照:https://syntagmatic.github.io/parallel-coordinates/ 和 https://github.com/syntagmatic/parallel-coo ...

  3. numpy多维矩阵,取出第一行或者第一列,方法和df一样

    # 定义一个多维矩阵 arr = np.array([[1,2,3], [4,5,6], [7,8,9]]) # 取出第一行 arr[0,:] # 取出第一列 arr[:,0]

  4. Java常见的错误种类

    数组中的错误: 越界: java.lang.ArrayIndexOutOfBoundsException 数组越界,如果声明 了5个元素的数组,但是在取值的时候用到了索引5,那就越界了 空指针:jav ...

  5. Python数据类型(元组)

    文章内容参考了教程:http://www.runoob.com/python/python-basic-syntax.html#commentform Python 元组 Python的元组与列表类似 ...

  6. 【随笔】MIME类型

    在openResty作为Web服务器的情况下访问根目录的首页时,出现了这样一个问题: nginx端的配置: worker_processes 2; error_log logs/error.log; ...

  7. 网络安装Ubuntu16.04

    网络安装Ubuntu16.04 搭建PXE服务器 PXE是Pre-boot Execution Environment,预启动执行环境.是通过网络安装任何linux系统最重要的步骤. 首选搭建PXE服 ...

  8. 远程连接postgresql和redis设置

    1. 让Postgresql服务器被远程访问 1.1 编辑 pg_hba.conf,配置用户的访问权限 vi /etc/postgresql/8.4/main/pg_hba.conf 增加设置项 ho ...

  9. html中 alt 和 title 的区别

    alt 用来给图片来提示的(图片载入失败时以文本形式提示). Title用来给链接文字或普通文字提示的(在鼠标放上去的时候就会提示).

  10. ExtJs6编译之后上线报错无法查看到的解决方法

    最近Extjs编译后部署遇到了一个错误c is not a constructor,报错位置在app.js里,这根本没法找 解决方法:用命令sencha app build testing 编译之后, ...