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"]); }
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)); }