Ejemplo n.º 1
0
        public void Insert1(IList <Hubble.Core.Data.Document> docs)
        {
            if (docs.Count <= 0)
            {
                return;
            }

            System.Data.DataTable table = new System.Data.DataTable();

            using (SQLiteDataProvider sqlData = new SQLiteDataProvider())
            {
                sqlData.Connect(Table.ConnectionString);

                System.Data.DataColumn col = new System.Data.DataColumn("DocId", typeof(int));
                table.Columns.Add(col);

                foreach (Data.FieldValue fv in docs[0].FieldValues)
                {
                    col = new System.Data.DataColumn(fv.FieldName, DataTypeConvert.GetClrType(fv.Type));

                    table.Columns.Add(col);
                }


                foreach (Hubble.Core.Data.Document doc in docs)
                {
                    System.Data.DataRow row = table.NewRow();

                    row[0] = doc.DocId;

                    int i = 1;

                    foreach (Data.FieldValue fv in doc.FieldValues)
                    {
                        row[i] = System.ComponentModel.TypeDescriptor.GetConverter(table.Columns[i].DataType).ConvertFrom(fv.Value);
                        i++;
                    }

                    table.Rows.Add(row);
                }

                table.TableName = _Table.DBTableName;

                sqlData.SaveDataTable(table);
            }
        }