Exemple #1
0
        public void ToSQL_004()
        {
            var data = new PersonInsert
            {
                FirstName = "Chris",
                LastName  = "Pietschmann"
            };
            var target = SQLinqHelper.Update(data);
            var actual = (SQLinqUpdateResult)target.ToSQL(42, "foo");

            Assert.AreEqual("[PersonInsert]", actual.Table);

            Assert.AreEqual(6, actual.Fields.Count);
            Assert.AreEqual("@foo43", actual.Fields["FirstName"]);
            Assert.AreEqual("@foo44", actual.Fields["LastName"]);
            Assert.AreEqual("@foo45", actual.Fields["Age"]);
            Assert.AreEqual("@foo46", actual.Fields["IsEmployed"]);
            Assert.AreEqual("@foo47", actual.Fields["ParentID"]);
            Assert.AreEqual("@foo48", actual.Fields["Column With Spaces"]);

            Assert.AreEqual(6, actual.Parameters.Count);
            Assert.AreEqual("Chris", actual.Parameters["@foo43"]);
            Assert.AreEqual("Pietschmann", actual.Parameters["@foo44"]);
            Assert.AreEqual(0, actual.Parameters["@foo45"]);
            Assert.AreEqual(false, actual.Parameters["@foo46"]);
            Assert.AreEqual(Guid.Empty, actual.Parameters["@foo47"]);
            Assert.AreEqual(null, actual.Parameters["@foo48"]);
        }
Exemple #2
0
        public void ToSQL_003()
        {
            var data = new
            {
                ID        = 1,
                FirstName = "Chris",
                LastName  = "Pietschmann",
                Age       = 0
            };
            var target = SQLinqHelper.Insert(data, "Person");
            var actual = (SQLinqInsertResult)target.ToSQL();

            Assert.Equal("[Person]", actual.Table);

            Assert.Equal(4, actual.Fields.Count);
            Assert.Equal("@sqlinq_1", actual.Fields["ID"]);
            Assert.Equal("@sqlinq_2", actual.Fields["FirstName"]);
            Assert.Equal("@sqlinq_3", actual.Fields["LastName"]);
            Assert.Equal("@sqlinq_4", actual.Fields["Age"]);

            Assert.Equal(4, actual.Parameters.Count);
            Assert.Equal(1, actual.Parameters["@sqlinq_1"]);
            Assert.Equal("Chris", actual.Parameters["@sqlinq_2"]);
            Assert.Equal("Pietschmann", actual.Parameters["@sqlinq_3"]);
            Assert.Equal(0, actual.Parameters["@sqlinq_4"]);
        }
        public void DynamicSQLinq_Create_001()
        {
            var expected = "tblPerson";
            var target   = SQLinqHelper.Create(expected);

            Assert.AreEqual(expected, target.TableName);
        }
Exemple #4
0
 public static SQLinqUpdate <T> ToSQLinqUpdate <T>(this T obj, string tableName = null, ISqlDialect dialect = null)
 {
     if (dialect == null)
     {
         dialect = DialectProvider.Create();
     }
     return(SQLinqHelper.Update(obj, tableName, dialect));
 }
        public void DynamicSQLinq_Oracle_Create_001()
        {
            var dialect  = new SQLinq.OracleDialect();
            var expected = "tblPerson";
            var target   = SQLinqHelper.Create(expected, dialect);

            Assert.AreEqual(expected, target.TableName);
        }
Exemple #6
0
        public void DynamicSQLinqSubQueryJoinExpression_ToSQL_003()
        {
            var query  = SQLinqHelper.Create("test");
            var alias  = "name";
            var clause = "1 = 1";
            var param1 = "test";
            var param2 = 2;

            var target = new DynamicSQLinqSubQueryJoinExpression(query, alias, clause, param1, param2);

            target.ToSQL(parameterNamePrefix: " ");
        }
Exemple #7
0
        public void DynamicSQLinqSubQueryJoinExpression_Constructor_001()
        {
            var query  = SQLinqHelper.Create("test");
            var alias  = "name";
            var clause = "1 = 1";
            var param1 = "test";
            var param2 = 2;

            var target = new DynamicSQLinqSubQueryJoinExpression(query, alias, clause, param1, param2);

            Assert.AreEqual(DynamicSQLinqJoinOperator.Inner, target.JoinOperator);

            Assert.AreEqual(query, target.Query);
            Assert.AreEqual(alias, target.Alias);
            Assert.AreEqual(clause, target.Clause);
            Assert.AreEqual(param1, target.Parameters[0]);
            Assert.AreEqual(param2, target.Parameters[1]);
        }