示例#1
0
		/// <summary>
		/// Get rows from table
		/// </summary>
		/// <param name="clause">SQL clause</param>
		/// <param name="parameters">SQL parameters</param>
		/// <param name="limit">Max row count to read</param>
		/// <param name="sqLiteConnection"></param>
		/// <returns></returns>
		private Int64? GetRowIdentity(string strQueryWhere, IEnumerable<SQLiteParameter> parameters)
		{
			Int64? identity = null;

			string sql = string.Format(
				"SELECT [{0}] FROM {1} WHERE {2} LIMIT 1;",
				IdentityField,
				this.TableDefinition.Name.AsDbName(),
				strQueryWhere
			);

			using (this.Connection.OpenWrapper())
			{
				SelectTableCommand commandSelect = new SelectTableCommand(
					this.Connection,
					this.TableDefinition,
					sql,
					parameters
				);

				commandSelect.Execute(100);

				if (commandSelect.Result != null)
				{
					if (commandSelect.Result.Count > 0L)
					{
						identity = (long?) commandSelect.Result.First().Values[IdentityField];
					}
				}
			}

			return identity;
		}
示例#2
0
		/// <summary>
		/// Get row by row id
		/// </summary>
		/// <param name="identity">Row identity</param>
		/// <returns></returns>
		public ITableRow GetRowByIdentity(Int64? identity)
		{
			string sql = string.Format(
				"SELECT {0} FROM {1} WHERE [{2}] = {3}",
				GetAllFieldsString(),
				this.TableDefinition.Name.AsDbName(),
				IdentityField,
				identity
			);

			using (this.Connection.OpenWrapper())
			{
				SelectTableCommand select = new SelectTableCommand(
					this.Connection,
					this.TableDefinition,
					sql,
					null
				);

				select.Execute(100);

				return select.Result.FirstOrDefault();
			}
		}
示例#3
0
		/// <summary>
		/// Get rows from table
		/// </summary>
		/// <param name="clause">SQL clause</param>
		/// <param name="parameters">SQL parameters</param>
		/// <param name="limit">Max row count to read</param>
		/// <param name="sqLiteConnection"></param>
		/// <returns></returns>
		public List<ITableRow> GetRows(string clause, IEnumerable<SQLiteParameter> parameters = null, int? limit = null)
		{
			string sql = string.Format(
				"SELECT {0} FROM {1}{2}{3};",
				GetAllFieldsString(),
				this.TableDefinition.Name.AsDbName(),
				(clause == null)
					? String.Empty
					: " WHERE " + clause,
				(limit != null)
					? " LIMIT " + limit
					: String.Empty
			);

			using (this.Connection.OpenWrapper())
			{
				SelectTableCommand commandSelect = new SelectTableCommand(
					this.Connection,
					this.TableDefinition,
					sql,
					parameters
				);

				commandSelect.Execute(100);

				return commandSelect.Result;
			}
		}