コード例 #1
0
        public void QueryObjectMustBeReutilizable()
        {
            var query = new CustomQuery <SingleKeyParentTable>(this.Fixture.Connector, this.Fixture.SelectClause);

            var result  = query.Execute();
            var result2 = query.Execute();

            result.Should().NotBeNull();
            result2.Should().NotBeNull();
            result2.Should().HaveSameCount(result);
        }
コード例 #2
0
        public void ShouldNotUseDisposedQueryObject()
        {
            var query = new CustomQuery <SingleKeyParentTable>(Fixture.Connector, Fixture.SelectClause);

            var result = query.Execute();

            query.Dispose();

            Action executeQuery = () => query.Execute();

            executeQuery.ShouldThrow <NullReferenceException>();
        }
コード例 #3
0
 /// <summary>
 /// Executes a query and return the results.
 /// </summary>
 /// <typeparam name="TResultType">The result type.</typeparam>
 /// <param name="connector">The database connector.</param>
 /// <param name="query">A custom commandText string. The select columns should be mapped to the <see cref="TResultType"/></param>
 /// /// <param name="whereClause">A where filter clause. Do not add the "WHERE" keyword to it. If you need to pass parameters, pass using @1, @2, @3.</param>
 /// <param name="parameters">A list of parameter values.</param>
 /// <returns>A list of <see cref="TResultType"/></returns>
 /// <seealso cref="Querying.CustomQuery{TResultType}"/>
 public static List <TResultType> CustomQuery <TResultType>(this IDatabaseConnector connector, string query, string whereClause = null, params object[] parameters) where TResultType : class, new()
 {
     using (var customQuery = new CustomQuery <TResultType>(connector, query))
     {
         return(customQuery.Execute(whereClause, parameters));
     }
 }
コード例 #4
0
        public void DisposingTwoTimesShouldBeOk()
        {
            var query = new CustomQuery <SingleKeyParentTable>(Fixture.Connector, Fixture.SelectClause);

            var result = query.Execute();

            query.Dispose();
            query.Dispose();
        }
コード例 #5
0
        public static string ExecuteSQL(string script, UserConnection userConnection)
        {
            script = script.Replace("|nl|", Environment.NewLine);
            var query = new CustomQuery(userConnection, script);
            var isChangeStateScript = GetIsChangeStateScript(script);

            if (isChangeStateScript)
            {
                var count = query.Execute();
                return(count.ToString());
            }
            var records   = query.ExecuteReader(userConnection.EnsureDBConnection());
            var dataTable = new DataTable {
                TableName = "bpmcliTable"
            };

            dataTable.Load(records);
            return(JsonConvert.SerializeObject(dataTable, Formatting.Indented));
        }