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 static SQLinqInsert <T> ToSQLinqInsert <T>(this T obj, string tableName = null, ISqlDialect dialect = null) { if (dialect == null) { dialect = DialectProvider.Create(); } return(SQLinqHelper.Insert(obj, tableName, dialect)); }