C# 导入Excel文件并插入RavenDB

C# 导入Excel文件并插入RavenDB,c#,asp.net-mvc,file-upload,ravendb,C#,Asp.net Mvc,File Upload,Ravendb,我想上传一个excel文件并将每条记录存储到RavenDb中 代码类似于 string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path1 + ";Extended Properties=Excel 12.0;Persist Security Info=False"; OleDbConnection excelConnection =

我想上传一个excel文件并将每条记录存储到RavenDb中

代码类似于

            string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path1 + ";Extended Properties=Excel 12.0;Persist Security Info=False";

            OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);

            OleDbCommand cmd = new OleDbCommand("Select * from [Sheet1$]", excelConnection);

            excelConnection.Open();
            OleDbDataReader dReader;
            dReader = cmd.ExecuteReader();

我不知道在executereader之后我需要做什么,任何人都可以向我展示解决方案???

你有使用RavenDB的经验吗

以下是一些要点:

  • 创建与RavenDB实例的连接。在您的情况下,使用嵌入式实例可能是最简单的:

    var documentStore = new EmbeddableDocumentStore{    DataDirectory = "Data"   };
    
  • 在documentstore上打开会话

  • 遍历查询返回的对象并将其保存到存储库:

    session.Store(entity); session.SaveChanges();
    
  • 这会让你上路的