BaseUpdateTests.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using PetaPoco.Core;
  5. using PetaPoco.Tests.Integration.Models;
  6. using Shouldly;
  7. using Xunit;
  8. namespace PetaPoco.Tests.Integration.Databases
  9. {
  10. public abstract class BaseUpdateTests : BaseDatabase
  11. {
  12. private Order _order = new Order
  13. {
  14. PoNumber = "Peta's Order",
  15. Status = OrderStatus.Accepted,
  16. CreatedOn = new DateTime(1948, 1, 11, 4, 2, 4, DateTimeKind.Utc),
  17. CreatedBy = "Harry"
  18. };
  19. private OrderLine _orderLine = new OrderLine
  20. {
  21. Quantity = 5,
  22. SellPrice = 4.99m,
  23. Status = OrderLineStatus.Pending
  24. };
  25. private Person _person = new Person
  26. {
  27. Id = Guid.NewGuid(),
  28. Age = 18,
  29. Dob = new DateTime(1945, 1, 12, 5, 9, 4, DateTimeKind.Utc),
  30. Height = 180,
  31. Name = "Peta"
  32. };
  33. protected BaseUpdateTests(DBTestProvider provider)
  34. : base(provider)
  35. {
  36. }
  37. [Fact]
  38. public void Update_GivenPoco_ShouldBeValid()
  39. {
  40. // Arrange
  41. DB.Insert(_person);
  42. _order.PersonId = _person.Id;
  43. DB.Insert(_order);
  44. _orderLine.OrderId = _order.Id;
  45. DB.Insert(_orderLine);
  46. // Act
  47. var personOther = DB.Single<Person>(_person.Id);
  48. UpdateProperties(personOther);
  49. DB.Update(personOther).ShouldBe(1);
  50. personOther = DB.Single<Person>(_person.Id);
  51. var orderOther = DB.Single<Order>(_order.Id);
  52. UpdateProperties(orderOther);
  53. DB.Update(orderOther).ShouldBe(1);
  54. orderOther = DB.Single<Order>(_order.Id);
  55. var orderLineOther = DB.Single<OrderLine>(_orderLine.Id);
  56. UpdateProperties(orderLineOther);
  57. DB.Update(orderLineOther).ShouldBe(1);
  58. orderLineOther = DB.Single<OrderLine>(_orderLine.Id);
  59. // Assert
  60. personOther.ShouldNotBe(_person, true);
  61. orderOther.ShouldNotBe(_order, true);
  62. orderLineOther.ShouldNotBe(_orderLine, true);
  63. }
  64. [Fact]
  65. public void Update_GivenPocoAndNullColumns_ShouldBeValid()
  66. {
  67. DB.Insert(_person);
  68. var personOther = DB.Single<Person>(_person.Id);
  69. UpdateProperties(personOther);
  70. DB.Update(personOther, null).ShouldBe(1);
  71. personOther = DB.Single<Person>(_person.Id);
  72. personOther.ShouldNotBe(_person, true);
  73. }
  74. [Fact]
  75. public void Update_GivenPocoColumns_ShouldBeValid()
  76. {
  77. DB.Insert(_person);
  78. var personOther = DB.Single<Person>(_person.Id);
  79. UpdateProperties(personOther);
  80. DB.Update(personOther, new[] { "FullName", "Height" }).ShouldBe(1);
  81. personOther = DB.Single<Person>(_person.Id);
  82. personOther.Id.ShouldBe(_person.Id);
  83. personOther.Age.ShouldBe(_person.Age);
  84. personOther.Dob.ShouldBe(_person.Dob);
  85. personOther.Name.ShouldNotBe(_person.Name);
  86. personOther.Height.ShouldNotBe(_person.Height);
  87. }
  88. [Fact]
  89. public void Update_GivenPocoAndPrimaryKey_ShouldBeValid()
  90. {
  91. DB.Insert(_person);
  92. var personOther = DB.Single<Person>(_person.Id);
  93. UpdateProperties(personOther);
  94. DB.Update(personOther, _person.Id).ShouldBe(1);
  95. personOther = DB.Single<Person>(_person.Id);
  96. personOther.ShouldNotBe(_person, true);
  97. }
  98. [Fact]
  99. public void Update_GivenPocoPrimaryKeyAndNullColumns_ShouldBeValid()
  100. {
  101. DB.Insert(_person);
  102. var personOther = DB.Single<Person>(_person.Id);
  103. UpdateProperties(personOther);
  104. DB.Update(personOther, _person.Id, null).ShouldBe(1);
  105. personOther = DB.Single<Person>(_person.Id);
  106. personOther.ShouldNotBe(_person, true);
  107. }
  108. [Fact]
  109. public void Update_GivenPocoPrimaryKeyAndColumns_ShouldBeValid()
  110. {
  111. DB.Insert(_person);
  112. var personOther = DB.Single<Person>(_person.Id);
  113. UpdateProperties(personOther);
  114. DB.Update(personOther, _person.Id, new[] { "FullName", "Height" }).ShouldBe(1);
  115. personOther = DB.Single<Person>(_person.Id);
  116. personOther.Id.ShouldBe(_person.Id);
  117. personOther.Age.ShouldBe(_person.Age);
  118. personOther.Dob.ShouldBe(_person.Dob);
  119. personOther.Name.ShouldNotBe(_person.Name);
  120. personOther.Height.ShouldNotBe(_person.Height);
  121. }
  122. [Fact]
  123. public void Update_GivenPocoAndEmptyColumns_ShouldBeValid()
  124. {
  125. DB.Insert(_person);
  126. var personOther = DB.Single<Person>(_person.Id);
  127. UpdateProperties(personOther);
  128. DB.Update(personOther, new string[0]).ShouldBe(0);
  129. personOther = DB.Single<Person>(_person.Id);
  130. personOther.Id.ShouldBe(_person.Id);
  131. personOther.Age.ShouldBe(_person.Age);
  132. personOther.Dob.ShouldBe(_person.Dob);
  133. personOther.Name.ShouldBe(_person.Name);
  134. personOther.Height.ShouldBe(_person.Height);
  135. }
  136. [Fact]
  137. public void Update_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValue_ShouldBeValid()
  138. {
  139. DB.Insert("SpecificPeople", "Id", false, _person);
  140. var personOther = SinglePersonOther(_person.Id);
  141. UpdateProperties(personOther);
  142. DB.Update("SpecificPeople", "Id", personOther, _person.Id).ShouldBe(1);
  143. personOther = SinglePersonOther(_person.Id);
  144. personOther.ShouldNotBe(_person, true);
  145. }
  146. [Fact]
  147. public void Update_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndNullColumns_ShouldBeValid()
  148. {
  149. DB.Insert("SpecificPeople", "Id", false, _person);
  150. var personOther = SinglePersonOther(_person.Id);
  151. UpdateProperties(personOther);
  152. DB.Update("SpecificPeople", "Id", personOther, _person.Id, null).ShouldBe(1);
  153. personOther = SinglePersonOther(_person.Id);
  154. personOther.ShouldNotBe(_person, true);
  155. }
  156. [Fact]
  157. public void Update_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndColumns_ShouldBeValid()
  158. {
  159. DB.Insert("SpecificPeople", "Id", false, _person);
  160. var personOther = SinglePersonOther(_person.Id);
  161. UpdateProperties(personOther);
  162. DB.Update("SpecificPeople", "Id", personOther, _person.Id, new[] { "FullName", "Height" }).ShouldBe(1);
  163. personOther = SinglePersonOther(_person.Id);
  164. personOther.Id.ShouldBe(_person.Id);
  165. personOther.Age.ShouldBe(_person.Age);
  166. personOther.Dob.ShouldBe(_person.Dob);
  167. personOther.Name.ShouldNotBe(_person.Name);
  168. personOther.Height.ShouldNotBe(_person.Height);
  169. }
  170. [Fact]
  171. public void Update_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndEmptyColumns_ShouldBeValid()
  172. {
  173. DB.Insert("SpecificPeople", "Id", false, _person);
  174. var personOther = SinglePersonOther(_person.Id);
  175. UpdateProperties(personOther);
  176. DB.Update("SpecificPeople", "Id", personOther, _person.Id, new string[0]).ShouldBe(0);
  177. personOther = SinglePersonOther(_person.Id);
  178. personOther.Id.ShouldBe(_person.Id);
  179. personOther.Age.ShouldBe(_person.Age);
  180. personOther.Dob.ShouldBe(_person.Dob);
  181. personOther.Name.ShouldBe(_person.Name);
  182. personOther.Height.ShouldBe(_person.Height);
  183. }
  184. [Fact]
  185. public void Update_GivenSqlAndParameters_ShouldBeValid()
  186. {
  187. DB.Insert(_person);
  188. var pd = PocoData.ForType(_person.GetType(), new ConventionMapper());
  189. var sql = $"SET {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName)} = @1 " +
  190. $"WHERE {DB.Provider.EscapeSqlIdentifier(pd.TableInfo.PrimaryKey)} = @0";
  191. DB.Update<Person>(sql, _person.Id, "Feta's Order").ShouldBe(1);
  192. var personOther = DB.Single<Person>(_person.Id);
  193. personOther.Id.ShouldBe(_person.Id);
  194. personOther.Name.ShouldNotBe(_person.Name);
  195. }
  196. [Fact]
  197. public void Update_GivenPocoUpdateSql_ShouldUpdateThePoco()
  198. {
  199. DB.Insert(_person);
  200. var pd = PocoData.ForType(_person.GetType(), new ConventionMapper());
  201. var sql = new Sql(
  202. $"SET {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName)} = @1 " +
  203. $"WHERE {DB.Provider.EscapeSqlIdentifier(pd.TableInfo.PrimaryKey)} = @0", _person.Id, "Feta's Order");
  204. DB.Update<Person>(sql);
  205. var personOther = DB.Single<Person>(_person.Id);
  206. personOther.Id.ShouldBe(_person.Id);
  207. personOther.Name.ShouldNotBe(_person.Name);
  208. }
  209. [Fact]
  210. public void Update_GivenNoPocoExists_ShouldBeValid()
  211. {
  212. var rowEffected = DB.Update(_person);
  213. rowEffected.ShouldBe(0);
  214. }
  215. [Fact]
  216. public void Update_GivenTablePrimaryKeyNameAndAnonymousType_ShouldBeValid()
  217. {
  218. DB.Insert(_person);
  219. DB.Update("People", "Id", new { _person.Id, FullName = "Feta", Age = 19, Dob = new DateTime(1946, 1, 12, 5, 9, 4, DateTimeKind.Utc), Height = 190 })
  220. .ShouldBe(1);
  221. var personOther = DB.Single<Person>(_person.Id);
  222. personOther.ShouldNotBe(_person, true);
  223. }
  224. [Fact]
  225. public void Update_GivenTablePrimaryKeyNameAnonymousTypeAndPrimaryKeyValue_ShouldBeValid()
  226. {
  227. DB.Insert(_person);
  228. DB.Update("People", "Id", new { FullName = "Feta", Age = 19, Dob = new DateTime(1946, 1, 12, 5, 9, 4, DateTimeKind.Utc), Height = 190 }, _person.Id)
  229. .ShouldBe(1);
  230. var personOther = DB.Single<Person>(_person.Id);
  231. personOther.ShouldNotBe(_person, true);
  232. }
  233. [Fact]
  234. public async Task UpdateAsync_GivenPoco_ShouldBeValid()
  235. {
  236. // Arrange
  237. await DB.InsertAsync(_person);
  238. _order.PersonId = _person.Id;
  239. await DB.InsertAsync(_order);
  240. _orderLine.OrderId = _order.Id;
  241. await DB.InsertAsync(_orderLine);
  242. // Act
  243. var personOther = await DB.SingleAsync<Person>(_person.Id);
  244. UpdateProperties(personOther);
  245. (await DB.UpdateAsync(personOther)).ShouldBe(1);
  246. personOther = DB.Single<Person>(_person.Id);
  247. var orderOther = await DB.SingleAsync<Order>(_order.Id);
  248. UpdateProperties(orderOther);
  249. (await DB.UpdateAsync(orderOther)).ShouldBe(1);
  250. orderOther = await DB.SingleAsync<Order>(_order.Id);
  251. var orderLineOther = await DB.SingleAsync<OrderLine>(_orderLine.Id);
  252. UpdateProperties(orderLineOther);
  253. (await DB.UpdateAsync(orderLineOther)).ShouldBe(1);
  254. orderLineOther = await DB.SingleAsync<OrderLine>(_orderLine.Id);
  255. // Assert
  256. personOther.ShouldNotBe(_person, true);
  257. orderOther.ShouldNotBe(_order, true);
  258. orderLineOther.ShouldNotBe(_orderLine, true);
  259. }
  260. [Fact]
  261. public async Task UpdateAsync_GivenPocoAndNullColumns_ShouldBeValid()
  262. {
  263. await DB.InsertAsync(_person);
  264. var personOther = await DB.SingleAsync<Person>(_person.Id);
  265. UpdateProperties(personOther);
  266. (await DB.UpdateAsync(personOther, null)).ShouldBe(1);
  267. personOther = await DB.SingleAsync<Person>(_person.Id);
  268. personOther.ShouldNotBe(_person, true);
  269. }
  270. [Fact]
  271. public async Task UpdateAsync_GivenPocoColumns_ShouldBeValid()
  272. {
  273. await DB.InsertAsync(_person);
  274. var personOther = await DB.SingleAsync<Person>(_person.Id);
  275. UpdateProperties(personOther);
  276. (await DB.UpdateAsync(personOther, new[] { "FullName", "Height" })).ShouldBe(1);
  277. personOther = await DB.SingleAsync<Person>(_person.Id);
  278. personOther.Id.ShouldBe(_person.Id);
  279. personOther.Age.ShouldBe(_person.Age);
  280. personOther.Dob.ShouldBe(_person.Dob);
  281. personOther.Name.ShouldNotBe(_person.Name);
  282. personOther.Height.ShouldNotBe(_person.Height);
  283. }
  284. [Fact]
  285. public async Task UpdateAsync_GivenPocoAndPrimaryKey_ShouldBeValid()
  286. {
  287. await DB.InsertAsync(_person);
  288. var personOther = await DB.SingleAsync<Person>(_person.Id);
  289. UpdateProperties(personOther);
  290. (await DB.UpdateAsync(personOther, _person.Id)).ShouldBe(1);
  291. personOther = await DB.SingleAsync<Person>(_person.Id);
  292. personOther.ShouldNotBe(_person, true);
  293. }
  294. [Fact]
  295. public async Task UpdateAsync_GivenPocoPrimaryKeyAndNullColumns_ShouldBeValid()
  296. {
  297. await DB.InsertAsync(_person);
  298. var personOther = await DB.SingleAsync<Person>(_person.Id);
  299. UpdateProperties(personOther);
  300. (await DB.UpdateAsync(personOther, _person.Id, null)).ShouldBe(1);
  301. personOther = await DB.SingleAsync<Person>(_person.Id);
  302. personOther.ShouldNotBe(_person, true);
  303. }
  304. [Fact]
  305. public async Task UpdateAsync_GivenPocoPrimaryKeyAndColumns_ShouldBeValid()
  306. {
  307. await DB.InsertAsync(_person);
  308. var personOther = await DB.SingleAsync<Person>(_person.Id);
  309. UpdateProperties(personOther);
  310. (await DB.UpdateAsync(personOther, _person.Id, new[] { "FullName", "Height" })).ShouldBe(1);
  311. personOther = await DB.SingleAsync<Person>(_person.Id);
  312. personOther.Id.ShouldBe(_person.Id);
  313. personOther.Age.ShouldBe(_person.Age);
  314. personOther.Dob.ShouldBe(_person.Dob);
  315. personOther.Name.ShouldNotBe(_person.Name);
  316. personOther.Height.ShouldNotBe(_person.Height);
  317. }
  318. [Fact]
  319. public async Task UpdateAsync_GivenPocoAndEmptyColumns_ShouldBeValid()
  320. {
  321. await DB.InsertAsync(_person);
  322. var personOther = await DB.SingleAsync<Person>(_person.Id);
  323. UpdateProperties(personOther);
  324. (await DB.UpdateAsync(personOther, new string[0])).ShouldBe(0);
  325. personOther = await DB.SingleAsync<Person>(_person.Id);
  326. personOther.Id.ShouldBe(_person.Id);
  327. personOther.Age.ShouldBe(_person.Age);
  328. personOther.Dob.ShouldBe(_person.Dob);
  329. personOther.Name.ShouldBe(_person.Name);
  330. personOther.Height.ShouldBe(_person.Height);
  331. }
  332. [Fact]
  333. public async Task UpdateAsync_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValue_ShouldBeValid()
  334. {
  335. await DB.InsertAsync("SpecificPeople", "Id", false, _person);
  336. var personOther = await SinglePersonOtherAsync(_person.Id);
  337. UpdateProperties(personOther);
  338. (await DB.UpdateAsync("SpecificPeople", "Id", personOther, _person.Id)).ShouldBe(1);
  339. personOther = await SinglePersonOtherAsync(_person.Id);
  340. personOther.ShouldNotBe(_person, true);
  341. }
  342. [Fact]
  343. public async Task UpdateAsync_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndNullColumns_ShouldBeValid()
  344. {
  345. await DB.InsertAsync("SpecificPeople", "Id", false, _person);
  346. var personOther = await SinglePersonOtherAsync(_person.Id);
  347. UpdateProperties(personOther);
  348. (await DB.UpdateAsync("SpecificPeople", "Id", personOther, _person.Id, null)).ShouldBe(1);
  349. personOther = await SinglePersonOtherAsync(_person.Id);
  350. personOther.ShouldNotBe(_person, true);
  351. }
  352. [Fact]
  353. public async Task UpdateAsync_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndColumns_ShouldBeValid()
  354. {
  355. await DB.InsertAsync("SpecificPeople", "Id", false, _person);
  356. var personOther = await SinglePersonOtherAsync(_person.Id);
  357. UpdateProperties(personOther);
  358. (await DB.UpdateAsync("SpecificPeople", "Id", personOther, _person.Id, new[] { "FullName", "Height" })).ShouldBe(1);
  359. personOther = await SinglePersonOtherAsync(_person.Id);
  360. personOther.Id.ShouldBe(_person.Id);
  361. personOther.Age.ShouldBe(_person.Age);
  362. personOther.Dob.ShouldBe(_person.Dob);
  363. personOther.Name.ShouldNotBe(_person.Name);
  364. personOther.Height.ShouldNotBe(_person.Height);
  365. }
  366. [Fact]
  367. public async Task UpdateAsync_GivenTablePrimaryKeyNamePocoAndPrimaryKeyValueAndEmptyColumns_ShouldBeValid()
  368. {
  369. await DB.InsertAsync("SpecificPeople", "Id", false, _person);
  370. var personOther = await SinglePersonOtherAsync(_person.Id);
  371. UpdateProperties(personOther);
  372. (await DB.UpdateAsync("SpecificPeople", "Id", personOther, _person.Id, new string[0])).ShouldBe(0);
  373. personOther = await SinglePersonOtherAsync(_person.Id);
  374. personOther.Id.ShouldBe(_person.Id);
  375. personOther.Age.ShouldBe(_person.Age);
  376. personOther.Dob.ShouldBe(_person.Dob);
  377. personOther.Name.ShouldBe(_person.Name);
  378. personOther.Height.ShouldBe(_person.Height);
  379. }
  380. [Fact]
  381. public async Task UpdateAsync_GivenSqlAndParameters_ShouldBeValid()
  382. {
  383. await DB.InsertAsync(_person);
  384. var pd = PocoData.ForType(_person.GetType(), new ConventionMapper());
  385. var sql = $"SET {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName)} = @1 " +
  386. $"WHERE {DB.Provider.EscapeSqlIdentifier(pd.TableInfo.PrimaryKey)} = @0";
  387. (await DB.UpdateAsync<Person>(sql, _person.Id, "Feta's Order")).ShouldBe(1);
  388. var personOther = await DB.SingleAsync<Person>(_person.Id);
  389. personOther.Id.ShouldBe(_person.Id);
  390. personOther.Name.ShouldNotBe(_person.Name);
  391. }
  392. [Fact]
  393. public async Task UpdateAsync_GivenPocoUpdateSql_ShouldUpdateThePoco()
  394. {
  395. await DB.InsertAsync(_person);
  396. var pd = PocoData.ForType(_person.GetType(), new ConventionMapper());
  397. var sql = new Sql(
  398. $"SET {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName)} = @1 " +
  399. $"WHERE {DB.Provider.EscapeSqlIdentifier(pd.TableInfo.PrimaryKey)} = @0", _person.Id, "Feta's Order");
  400. await DB.UpdateAsync<Person>(sql);
  401. var personOther = await DB.SingleAsync<Person>(_person.Id);
  402. personOther.Id.ShouldBe(_person.Id);
  403. personOther.Name.ShouldNotBe(_person.Name);
  404. }
  405. [Fact]
  406. public async Task UpdateAsync_GivenNoPocoExists_ShouldBeValid()
  407. {
  408. var rowEffected = await DB.UpdateAsync(_person);
  409. rowEffected.ShouldBe(0);
  410. }
  411. [Fact]
  412. public async Task UpdateAsync_GivenTablePrimaryKeyNameAndAnonymousType_ShouldBeValid()
  413. {
  414. await DB.InsertAsync(_person);
  415. (await DB.UpdateAsync("People", "Id",
  416. new { _person.Id, FullName = "Feta", Age = 19, Dob = new DateTime(1946, 1, 12, 5, 9, 4, DateTimeKind.Utc), Height = 190 })).ShouldBe(1);
  417. var personOther = await DB.SingleAsync<Person>(_person.Id);
  418. personOther.ShouldNotBe(_person, true);
  419. }
  420. [Fact]
  421. public async Task UpdateAsync_GivenTablePrimaryKeyNameAnonymousTypeAndPrimaryKeyValue_ShouldBeValid()
  422. {
  423. await DB.InsertAsync(_person);
  424. (await DB.UpdateAsync("People", "Id", new { FullName = "Feta", Age = 19, Dob = new DateTime(1946, 1, 12, 5, 9, 4, DateTimeKind.Utc), Height = 190 },
  425. _person.Id)).ShouldBe(1);
  426. var personOther = await DB.SingleAsync<Person>(_person.Id);
  427. personOther.ShouldNotBe(_person, true);
  428. }
  429. private Person SinglePersonOther(Guid id)
  430. => DB.Single<Person>($"SELECT * From {DB.Provider.EscapeTableName("SpecificPeople")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0", id);
  431. private Task<Person> SinglePersonOtherAsync(Guid id)
  432. => DB.SingleAsync<Person>($"SELECT * From {DB.Provider.EscapeTableName("SpecificPeople")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0", id);
  433. private static void UpdateProperties(Person person)
  434. {
  435. person.Name = "Feta";
  436. person.Age = 19;
  437. person.Dob = new DateTime(1946, 1, 12, 5, 9, 4, DateTimeKind.Utc);
  438. person.Height = 190;
  439. }
  440. private static void UpdateProperties(Order order)
  441. {
  442. order.PoNumber = "Feta's Order";
  443. order.Status = OrderStatus.Pending;
  444. order.CreatedOn = new DateTime(1949, 1, 11, 4, 2, 4, DateTimeKind.Utc);
  445. order.CreatedBy = "Jen";
  446. }
  447. private static void UpdateProperties(OrderLine orderLine)
  448. {
  449. orderLine.Quantity = 6;
  450. orderLine.SellPrice = 5.99m;
  451. orderLine.Status = OrderLineStatus.Allocated;
  452. }
  453. }
  454. }