Exemple #1
0
        /// <inheritdoc />
        public override IList <TValue> GetValues <TValue>(string fieldname, Search search = null)
        {
            var escapedFieldName = Storage.EscapeFieldName(Layout[fieldname]);
            var field            = new FieldProperties
            {
                Name           = fieldname,
                NameAtDatabase = fieldname,
                Flags          = FieldFlags.None,
                DataType       = DataType.String,
                TypeAtDatabase = DataType.String
            };

            field.Validate();
            SqlCmd query;

            if (search == null)
            {
                query = $"SELECT {escapedFieldName} FROM {FQTN}";
            }
            else
            {
                var s = ToSqlSearch(search);
                query = new SqlCmd($"SELECT {escapedFieldName} FROM {FQTN} WHERE {s}", s.Parameters);
            }

            var rows   = Storage.Query(query, Database.Name, Name);
            var result = new List <TValue>();

            foreach (var row in rows)
            {
                var value = (TValue)Fields.ConvertValue(typeof(TValue), row[0], CultureInfo.InvariantCulture);
                result.Add(value);
            }

            return(result.AsList());
        }
Exemple #2
0
        /// <summary>Queries for all matching datasets.</summary>
        /// <param name="cmd">The database dependent sql statement.</param>
        /// <returns>The result rows.</returns>
        public IList <Row> Query(SqlCmd cmd)
        {
            var layout = Layout;

            return(Query(cmd, ref layout));
        }
Exemple #3
0
 /// <summary>Queries for all matching datasets.</summary>
 /// <param name="cmd">The database dependent sql statement.</param>
 /// <param name="layout">The expected schema layout (if unset the layout is returned).</param>
 /// <returns>The result rows.</returns>
 public IList <Row> Query(SqlCmd cmd, ref RowLayout layout) => Storage.Query(cmd, ref layout, Database.Name, Name);
Exemple #4
0
 /// <summary>Executes a database dependent sql statement silently.</summary>
 /// <param name="cmd">the database dependent sql statement.</param>
 /// <returns>Number of affected rows (if supported by the database).</returns>
 public int Execute(SqlCmd cmd) => Storage.Execute(cmd, Database.Name, Name);
Exemple #5
0
 /// <summary>Querys a single value with a database dependent sql statement.</summary>
 /// <param name="cmd">The database dependent sql statement.</param>
 /// <param name="fieldName">Name of the field (optional, only needed if multiple columns are returned).</param>
 /// <returns>The result value or null.</returns>
 public object QueryValue(SqlCmd cmd, string fieldName = null)
 => Storage.QueryValue(cmd, Database.Name, Name, fieldName);
Exemple #6
0
 /// <summary>Querys a single value with a database dependent sql statement.</summary>
 /// <param name="cmd">The database dependent sql statement.</param>
 /// <param name="value">The result.</param>
 /// <param name="fieldName">Name of the field (optional, only needed if multiple columns are returned).</param>
 /// <returns>true if the value could be found and read, false otherwise.</returns>
 /// <typeparam name="TValue">Result value type.</typeparam>
 public bool QueryValue <TValue>(SqlCmd cmd, out TValue value, string fieldName = null)
     where TValue : struct
 => Storage.QueryValue(cmd, out value, Database.Name, Name, fieldName);
Exemple #7
0
        /// <summary>Queries for a dataset (selected fields, one row).</summary>
        /// <param name="cmd">The database dependent sql statement.</param>
        /// <returns>The result row.</returns>
        public Row QueryRow(SqlCmd cmd)
        {
            var layout = Layout;

            return(QueryRow(cmd, ref layout));
        }
Exemple #8
0
 /// <summary>Queries for a dataset (selected fields, one row).</summary>
 /// <param name="cmd">The database dependent sql statement.</param>
 /// <param name="layout">The expected schema layout (if unset the layout is returned).</param>
 /// <returns>The result row.</returns>
 public Row QueryRow(SqlCmd cmd, ref RowLayout layout) => Query(cmd, ref layout).Single();