Beispiel #1
0
 public TableQuery(SQLiteConnection conn)
 {
     Connection = conn;
     Table      = Connection.GetMapping(typeof(T));
 }
Beispiel #2
0
 TableQuery(SQLiteConnection conn, TableMapping table)
 {
     Connection = conn;
     Table      = table;
 }
Beispiel #3
0
 /// <summary>
 /// Attempts to retrieve an object with the given primary key from the table
 /// associated with the specified type. Use of this method requires that
 /// the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).
 /// </summary>
 /// <param name="pk">
 /// The primary key.
 /// </param>
 /// <param name="map">
 /// The TableMapping used to identify the object type.
 /// </param>
 /// <returns>
 /// The object with the given primary key or null
 /// if the object is not found.
 /// </returns>
 public object Find(object pk, TableMapping map)
 {
     return(Query(map, map.GetByPrimaryKeySql, pk).FirstOrDefault());
 }
Beispiel #4
0
        /// <summary>
        /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
        /// in the command text for each of the arguments and then executes that command.
        /// It returns each row of the result using the specified mapping. This function is
        /// only used by libraries in order to query the database via introspection. It is
        /// normally not used.
        /// </summary>
        /// <param name="map">
        /// A <see cref="TableMapping"/> to use to convert the resulting rows
        /// into objects.
        /// </param>
        /// <param name="query">
        /// The fully escaped SQL.
        /// </param>
        /// <param name="args">
        /// Arguments to substitute for the occurences of '?' in the query.
        /// </param>
        /// <returns>
        /// An enumerable with one result for each row returned by the query.
        /// The enumerator will call sqlite3_step on each call to MoveNext, so the database
        /// connection must remain open for the lifetime of the enumerator.
        /// </returns>
        public IEnumerable <object> DeferredQuery(TableMapping map, string query, params object[] args)
        {
            var cmd = CreateCommand(query, args);

            return(cmd.ExecuteDeferredQuery <object>(map));
        }
Beispiel #5
0
        /// <summary>
        /// Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?'
        /// in the command text for each of the arguments and then executes that command.
        /// It returns each row of the result using the specified mapping. This function is
        /// only used by libraries in order to query the database via introspection. It is
        /// normally not used.
        /// </summary>
        /// <param name="map">
        /// A <see cref="TableMapping"/> to use to convert the resulting rows
        /// into objects.
        /// </param>
        /// <param name="query">
        /// The fully escaped SQL.
        /// </param>
        /// <param name="args">
        /// Arguments to substitute for the occurences of '?' in the query.
        /// </param>
        /// <returns>
        /// An enumerable with one result for each row returned by the query.
        /// </returns>
        public List <object> Query(TableMapping map, string query, params object[] args)
        {
            var cmd = CreateCommand(query, args);

            return(cmd.ExecuteQuery <object> (map));
        }
Beispiel #6
0
 public List <T> ExecuteQuery <T> (TableMapping map)
 {
     return(ExecuteDeferredQuery <T>(map).ToList());
 }