/// <summary>
        ///     Return JSONArray for one row of data from the statement
        /// </summary>
        /// <param name="statement"></param>
        /// <returns></returns>
        private JArray GetDataFromRow(ISQLiteStatement statement)
        {
            var row         = new JArray();
            int columnCount = statement.ColumnCount;

            for (int i = 0; i < columnCount; i++)
            {
                if (statement.ColumnName(i).EndsWith(SoupCol))
                {
                    string raw = statement.GetText(i);
                    row.Add(JObject.Parse(raw));
                }
                else
                {
                    object raw = GetObject(statement, i);
                    if (raw != null)
                    {
                        long value;
                        if (long.TryParse(raw.ToString(), out value))
                        {
                            row.Add(new JValue(value));
                        }
                        else
                        {
                            double dvalue;
                            if (double.TryParse(raw.ToString(), out dvalue))
                            {
                                row.Add(new JValue(dvalue));
                            }
                            else
                            {
                                row.Add(raw.ToString());
                            }
                        }
                    }
                }
            }
            return(row);
        }
        private JObject ReadRow(TableDefinition table, ISQLiteStatement statement)
        {
            var row = new JObject();

            for (int i = 0; i < statement.ColumnCount; i++)
            {
                string name  = statement.ColumnName(i);
                object value = statement[i];

                ColumnDefinition column;
                if (table.TryGetValue(name, out column))
                {
                    JToken jVal = SqlHelpers.DeserializeValue(value, column.StoreType, column.JsonType);
                    row[name] = jVal;
                }
                else
                {
                    row[name] = value == null ? null : JToken.FromObject(value);
                }
            }
            return(row);
        }
Example #3
0
        private static Region ParseRegion(ISQLiteStatement row)
        {
            var region = new Region();

            for (int x = 0; x < row.ColumnCount; x++)
            {
                var columnLabel = row.ColumnName(x);
                if (typeof(Region).HasProperty(columnLabel))
                {
                    SQLiteType dataType = row.DataType(x);
                    if (dataType == SQLiteType.INTEGER)
                    {
                        region.Id = int.Parse(row[x].ToString());
                    }
                    else
                    {
                        region.Name = row[x] as string;
                    }
                }
            }
            return(region);
        }
 /// <summary>
 ///     Return JSONArray for one row of data from the statement
 /// </summary>
 /// <param name="statement"></param>
 /// <returns></returns>
 private JArray GetDataFromRow(ISQLiteStatement statement)
 {
     var row = new JArray();
     int columnCount = statement.ColumnCount;
     for (int i = 0; i < columnCount; i++)
     {
         if (statement.ColumnName(i).EndsWith(SoupCol))
         {
             string raw = statement.GetText(i);
             row.Add(JObject.Parse(raw));
         }
         else
         {
             object raw = GetObject(statement, i);
             if (raw != null)
             {
                 long value;
                 if (long.TryParse(raw.ToString(), out value))
                 {
                     row.Add(new JValue(value));
                 }
                 else
                 {
                     double dvalue;
                     if (double.TryParse(raw.ToString(), out dvalue))
                     {
                         row.Add(new JValue(dvalue));
                     }
                     else
                     {
                         row.Add(raw.ToString());
                     }
                 }
             }
         }
     }
     return row;
 }
        private JObject ReadRow(TableDefinition table, ISQLiteStatement statement)
        {
            var row = new JObject();
            for (int i = 0; i < statement.ColumnCount; i++)
            {
                string name = statement.ColumnName(i);
                object value = statement[i];

                ColumnDefinition column;
                if (table.TryGetValue(name, out column))
                {
                    JToken jVal = SqlHelpers.DeserializeValue(value, column.StoreType, column.JsonType);
                    row[name] = jVal;
                }
                else
                {
                    row[name] = value == null ? null : JToken.FromObject(value);
                }
            }
            return row;
        }