BulkInsertNode() public method

Bulk insert node from data file into node table.
public BulkInsertNode ( string dataFileName, string tableName, string tableSchema = "dbo", IList dataColumnName = null, string fieldTerminator = "\t", string rowTerminator = "\r\n", bool skipHeader = false ) : void
dataFileName string The name of data file.
tableName string The table name of node table.
tableSchema string The Schema name of node table. Default by "dbo".
dataColumnName IList User-supplied column(s) in data file in order. /// By default(null or empty), data file should exactly contain all the columns of property and nodeid in creating order.
fieldTerminator string The field terminator of data file. Default by "\t".
rowTerminator string The row terminator of data file. Default by "\r\n".
skipHeader bool
return void
コード例 #1
0
        public static void run()
        {
            GraphViewConnection con = new GraphViewConnection(TutorialConfiguration.getConnectionString());
            con.Open();
            con.ClearData();
            try
            {
                generateFiles();

                Console.WriteLine("Creating tables...");
                #region Create a schema for reader and book
                con.CreateNodeTable(@"CREATE TABLE [Book] ( 
                    [ColumnRole:""NodeId""] name VARCHAR(40) )");

                con.CreateNodeTable(@"CREATE TABLE [Reader] ( 
                    [ColumnRole:""NodeId""] name VARCHAR(30),
                    [ColumnRole:""Property""] gender VARCHAR(10),
                    [ColumnRole:""Edge"",Reference:""Book""] Reads VARBINARY(max) )");
                #endregion

                Console.WriteLine("BulkLoading...");
                #region Bulk Load Nodes
                con.BulkInsertNode(ReaderFileName, "Reader", "dbo", null, ",", "\n");
                con.BulkInsertNode(BookFileName, "Book", "dbo", null, ",", "\n");
                con.BulkInsertEdge(readRelationFileName, "dbo", "Reader", "name", "Book", "name", "Reads", null, ",", "\n");
                #endregion

                Console.WriteLine("Querying...");
                #region Query
                var res = con.ExecuteReader(@"SELECT x.name as name1, y.name as name2 FROM Reader x, Book y
                                MATCH x-[Reads]->y ");
                try
                {
                    while (res.Read())
                    {
                        System.Console.WriteLine(res["name1"].ToString() + " Reads " + res["name2"].ToString());
                    }
                }
                finally
                {
                    if (res != null)
                        res.Close();
                }
                #endregion
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
            finally //  close the connection and drop table
            {
                con.ClearGraphDatabase();
                con.Close();
                deleteFiles();
            }
        }