Exemple #1
0
        public EbDataRow GetAsDataRow()
        {
            EbDataRow   row = null;
            EbDataTable dt  = new EbDataTable();

            if (Parameters != null && Parameters.Any())
            {
                row = dt.NewDataRow();
                dt.Rows.Add(row);

                List <object> dataArray = new List <object>();

                for (int i = 0; i < Parameters.Count; i++)
                {
                    EbMobileStaticParameter pm = Parameters[i];

                    dt.Columns.Add(new EbDataColumn
                    {
                        ColumnName  = pm.Name,
                        ColumnIndex = i
                    });

                    dataArray.Add(pm.Value);
                }
                row.AddRange(dataArray.ToArray());
            }
            return(row ?? dt.NewDataRow());
        }
        protected void PrepareDataTable(SqliteDataReader reader, EbDataTable dt)
        {
            try
            {
                int _fieldCount = reader.FieldCount;

                for (int i = 0; i < _fieldCount; i++)
                {
                    dt.Columns.Add(new EbDataColumn
                    {
                        ColumnName  = reader.GetName(i),
                        ColumnIndex = i,
                        Type        = DbTypeConverter.ConvertToDbType(reader.GetFieldType(i))
                    });
                }

                while (reader.Read())
                {
                    EbDataRow dr     = dt.NewDataRow();
                    object[]  oArray = new object[_fieldCount];
                    reader.GetValues(oArray);
                    dr.AddRange(oArray);
                    dt.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }