我已经映射了实体框架实体.SQL Server 2008中的每个表都包含Timestamp列,该列被映射为字节数组.数组的长度始终为8.
现在我需要比较.NET中的时间戳值.我有两个解决方案,但我不知道哪个更好?
哪种解决方案更好?或者还有其他解决方案吗?
我们有一个ASP.Net MVC应用程序,它使用EF4作为其数据访问层,我们看到当我们认为它们应该是没有抛出OptimisitcConcurrencyExceptions时的意外行为.
我们已将问题简化为以下代码...
using System.Linq;
using Project.Model;
namespace OptimisticConcurrency
{
class Program
{
static void Main()
{
Contact firstContact = null;
using (var firstEntities = new ProjectEntities())
{
firstContact = (from c in firstEntities.Contacts
where c.LastName == "smith" select c).Single();
}
using (var secondEntities = new ProjectEntities())
{
var secondContact = (from c in secondEntities.Contacts
where c.LastName == "smith" select c).Single();
secondContact.Title = "a";
secondEntities.SaveChanges();
}
firstContact.Title = "b";
using (var thirdEntities = new ProjectEntities())
{
var thirdContact = (from …Run Code Online (Sandbox Code Playgroud)