コード例 #1
0
ファイル: Document.cs プロジェクト: wj60387/hubble
        public static Hubble.Framework.Data.DataSet ToDataSet(List <Field> schema, List <Document> docs)
        {
            Hubble.Framework.Data.DataTable dt = new Hubble.Framework.Data.DataTable();

            foreach (Field field in  schema)
            {
                Hubble.Framework.Data.DataColumn col = new Hubble.Framework.Data.DataColumn(field.Name,
                                                                                            DataTypeConvert.GetClrType(field.DataType));
                dt.Columns.Add(col);
            }

            foreach (Document doc in docs)
            {
                Hubble.Framework.Data.DataRow row = dt.NewRow();

                foreach (FieldValue fv in doc.FieldValues)
                {
                    if (fv.Value == null)
                    {
                        row[fv.FieldName] = System.DBNull.Value;
                    }
                    else
                    {
                        Type type = DataTypeConvert.GetClrType(fv.Type);

                        if (fv.Type == DataType.TinyInt)
                        {
                            bool bitValue;

                            //check the bit data type of database
                            if (bool.TryParse(fv.Value, out bitValue))
                            {
                                if (bitValue)
                                {
                                    row[fv.FieldName] = (byte)1;
                                }
                                else
                                {
                                    row[fv.FieldName] = (byte)0;
                                }

                                continue;
                            }
                        }

                        row[fv.FieldName] =
                            System.ComponentModel.TypeDescriptor.GetConverter(type).ConvertFrom(fv.Value);
                    }
                }

                dt.Rows.Add(row);
            }

            Hubble.Framework.Data.DataSet ds = new Hubble.Framework.Data.DataSet();
            ds.Tables.Add(dt);
            return(ds);
        }
コード例 #2
0
ファイル: ParseGroupByCount.cs プロジェクト: wj60387/hubble
        unsafe private Hubble.Framework.Data.DataTable GetTable(ulong[] keyList, int relCount)
        {
            GroupByPair[] groupByPair = GetGroupByPairs(keyList, relCount);
            //GroupByPair[] groupByPair = new GroupByPair[groupByDict.Count];

            //int i = 0;

            //foreach(ulong key in groupByDict.Keys)
            //{
            //    groupByPair[i++] = new GroupByPair(key, groupByDict[key]);
            //}

            Array.Sort(groupByPair);

            Hubble.Framework.Data.DataTable table = new Hubble.Framework.Data.DataTable();

            foreach (Field field in _GroupByFields)
            {
                Hubble.Framework.Data.DataColumn col = new Hubble.Framework.Data.DataColumn(field.Name,
                                                                                            DataTypeConvert.GetClrType(field.DataType));

                table.Columns.Add(col);
            }

            table.Columns.Add(new Hubble.Framework.Data.DataColumn("Count", typeof(int)));

            foreach (GroupByPair gbp in groupByPair)
            {
                Hubble.Framework.Data.DataRow row = table.NewRow();

                int preDataLength = 0;
                int col           = _GroupByFields.Count - 1;

                for (; col >= 0; col--)
                {
                    row[col] = GetFieldValue(_GroupByFields[col], ref preDataLength, gbp.Key);
                }

                row[_GroupByFields.Count] = gbp.Count;

                table.Rows.Add(row);

                if (table.Rows.Count >= _Top)
                {
                    break;
                }
            }

            table.TableName       = "GroupByCount_" + _GroupByFieldsString;
            table.MinimumCapacity = groupByPair.Length;

            return(table);
        }
コード例 #3
0
ファイル: StoredProcedure.cs プロジェクト: wj60387/hubble
        protected void OutputValue(string columnName, object value)
        {
            Hubble.Framework.Data.DataTable table = _QueryResult.DataSet.Tables[0];

            if (table.Rows.Count == 0)
            {
                table.Rows.Add(table.NewRow());
            }

            if (value == null)
            {
                table.Rows[table.Rows.Count - 1][columnName] = DBNull.Value;
            }
            else
            {
                table.Rows[table.Rows.Count - 1][columnName] = value;
            }
        }
コード例 #4
0
ファイル: StoredProcedure.cs プロジェクト: wj60387/hubble
        protected void NewRow()
        {
            Hubble.Framework.Data.DataTable table = _QueryResult.DataSet.Tables[0];

            table.Rows.Add(table.NewRow());
        }