Description: devstak builds and runs websites for small and medium-sized businesses. Every plan includes your site, hosting, automation and support.
A full stack development blog focusing on Microsoft technologies
//query 1 var order1 = context.Orders.Single(order => order.OrderId == 1); //query 2 var order2 = context.Orders.Single(order => order.OrderId == 1); Upon the first query executing the order entity is cached internally within the framework. Upon the second query executing another SQL statement is executed and the current order entity in the cache is updated. The references of order1 and order2 would point to the same object in memory. One might argue that the second query shouldn't execute a SQL statemen
Although I’m against it many developers place business logic regardless of complexity into the database through the use of inline case statements where this could be a simple calculation to calculate a shipping cost for example. As the database grows and the number of SQL queries increases where they have a dependency on this calculation it becomes good practice to centralise the code for reuse rather than duplicating the logic in numerous queries.