Undo changes in entity framework entities

this might be a trivial question but: Since ADO.NET entity framework automatically tracks changes (in generated entities) and therefore keeps the original values, how can I rollback changes made to the entity objects? I have a form which allows the user to edit a set of "Customer" entities in a grid view. Now I have two buttons "Accept" and "Revert": if "Acc

撤消实体框架实体中的更改

这可能是一个微不足道的问题,但是:由于ADO.NET实体框架自动跟踪更改(在生成的实体中)并因此保留原始值,因此我如何回滚对实体对象所做的更改? 我有一个允许用户在网格视图中编辑一组“客户”实体的表单。 现在我有两个按钮“接受”和“恢复”:如果单击“接受”,我调用Context.SaveChanges()并将更改的对象写回数据库。 如果单击“恢复”,我希望所有对象都能获得其原始属性值。 那会是什么代码? 谢谢 EF中没有恢复或取消

Entity Framework 4.0: is it worthy now?

I've read a lot complains about Entity Framework in .NET 3.5 SP1, especially about its ineffectively generated SQL. Those complains had prevented me from studying Entity Framework. Now Entity Framework 4.0 has come out, which provide a lot of promises. I wonder if it's really a good ORM now, or still not yet? Is it worth to learn and use it in my .NET projects, instead of traditional

实体框架4.0:现在值得吗?

我读过很多关于.NET 3.5 SP1中的实体框架的抱怨,特别是关于其无效生成的SQL。 那些抱怨让我无法研究实体框架。 现在Entity Framework 4.0已经出来,它提供了许多承诺。 我想知道它现在是否真的是一个好的ORM,还是还没有? 是否值得在我的.NET项目中学习和使用它,而不是传统的SQL查询? 你有计划转换到EF 4.0吗? 提前致谢。 一个字: 是的! 实体框架4.0包含大量的增加和改进,以及POCO和自我跟踪实体的附加模板

Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable 's to have the Any() and Count() extension methods. I was told recently that if i want to check that a collection contains 1 or more items inside it, I should use the .Any() extension method instead of the .Count() > 0 extension method because the .Count() extension method has to iterate through all the items. Secondly, so

哪个方法执行得更好:.Any()vs .Count()> 0?

在System.Linq命名空间中,我们现在可以扩展IEnumerable的Any()和Count()扩展方法。 最近,我被告知,如果我要检查一个集合包含在它里面1个或多个项目,我应该使用.Any()而不是扩展方法.Count() > 0扩展方法,因为.Count()扩展方法必须遍历所有项目。 其次,一些集合有一个属性(不是扩展方法),它是Count或Length 。 它会更好利用这些,而不是.Any()或.Count() 是/娜? 如果你开始的东西,有一个.Length或.Count

Removing branch mapping in Team Foundation Server 2010

I've got a solution in source control with multiple projects. When I first migrated old code to TFS, I created main, dev, release areas for branches. Being new to TFS at the time, I branched a single project to the dev area, which created the little silver branch icon to show the relationship between them. Having done that, of course, I can no longer branch above or below that spot. So, I

在Team Foundation Server 2010中删除分支映射

我有多个项目的源代码控制解决方案。 当我第一次将旧代码迁移到TFS时,我为分支创建了主要,开发,发布区域。 作为当时的TFS新手,我将一个项目分支到开发区,创建了一个银色的小分支图标来展示它们之间的关系。 当然,完成这些之后,我不能再在该点之上或之下分支。 所以,我不能分支整个解决方案。 我尝试删除分支的映射/关联,以便我可以从树中的较高分支中分支,但无法找到这样做的方法。 我备份了源代码管理,并删除

Call and Callvirt

CIL指令“Call”和“Callvirt”之间有什么区别? call is for calling non-virtual, static, or superclass methods, ie, the target of the call is not subject to overriding. callvirt is for calling virtual methods (so that if this is a subclass that overrides the method, the subclass version is called instead). When the runtime executes a call instruction it's making a call to an exact piece of code

Call和Callvirt

CIL指令“Call”和“Callvirt”之间有什么区别? call用于调用非虚拟,静态或超类方法,即调用的目标不受覆盖。 callvirt用于调用虚拟方法(因此,如果this是覆盖方法的子类,则调用子类版本)。 当运行时执行一个call指令时,它会调用一段精确的代码(方法)。 毫无疑问,它存在于何处。 一旦IL被打出,在呼叫地点产生的机器码就是无条件的jmp指令。 相反, callvirt指令用于以多态方式调用虚拟方法。 方法代码的确切位置

Can't locate fuslogvw.exe on my machine

I'm looking for the assembly binding log viewer executable (fuslogvw.exe), but I can't seem to find it on my machine. It's there for sure, because when I type fuslogvw in a Visual Studio command prompt the application opens. The machine I'm working on has a clean Visual Studio 2008 installation, no previous versions were ever installed. Anyone knows where to find it? I need

在我的机器上找不到fuslogvw.exe

我正在查找程序集绑定日志查看器可执行文件(fuslogvw.exe),但我似乎无法在我的机器上找到它。 这是肯定的,因为当我在Visual Studio命令提示符下键入fuslogvw时,应用程序将打开。 我正在使用的计算机有一个干净的Visual Studio 2008安装,以前没有安装任何版本。 任何人都知道在哪里找到它? 我需要该exe能够将其复制到服务器来解决绑定问题。 在我的盒子里,也可以在VS2008上找到它 C: Program Files Microsoft

Implementing MVC with Windows Forms

Where can I find a good example on how to completely implement the MVC pattern in Windows Forms? I found many tutorials and code examples on various sites (for example, The Code Project and .NetHeaven), but many are more representative for the observer pattern than MVC. Since the application I want to develop is for a school project, I am reluctant to using frameworks like PureMVC or MVC#. I

用Windows Forms实现MVC

我在哪里可以找到一个关于如何在Windows Forms中完全实现MVC模式的好例子? 我在各种网站上找到了许多教程和代码示例(例如,Code Project和.NetHeaven),但许多代表观察者模式比MVC更具代表性。 由于我想开发的应用程序是针对学校项目的,因此我不愿意使用PureMVC或MVC#等框架。 我认为应用程序如此不同,我们对如何编写应用程序的理解仍然非常有限。 我曾经工作过的Windows窗体应用程序已经彼此不同。 我看到的一些设

Why does StreamReader.ReadLine throw OutOfMemoryException?

谁能告诉我为什么这里的最后一行会引发OOM异常? byte[] buffer = new byte[1]; buffer[0] = 239; MemoryStream ms = new MemoryStream(buffer); StreamReader sr = new StreamReader(ms); string l1 = sr.ReadLine(); string l2 = sr.ReadLine(); Congratulations, you've found a bug in the .NET framework. It is induced by the byte value, 0xef in hex. Which is t

为什么StreamReader.ReadLine抛出OutOfMemoryException?

谁能告诉我为什么这里的最后一行会引发OOM异常? byte[] buffer = new byte[1]; buffer[0] = 239; MemoryStream ms = new MemoryStream(buffer); StreamReader sr = new StreamReader(ms); string l1 = sr.ReadLine(); string l2 = sr.ReadLine(); 恭喜,您在.NET框架中发现了一个错误。 它由十六进制中的字节值0xef引起。 这是UTF-8 BOM的第一个字节。 这当然不是一个完整

Entity Framework and Connection Pooling

I've recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling. Connection pooling as I know is managed by the ADO.NET data provider, in my case that of MS SQL server. Does this apply when you instantiate a new entities context ( ObjectContext ), ie the parameterless new MyDatabaseModelEntities() ? What are the advan

实体框架和连接池

我最近开始在我的.NET 4.0应用程序中使用Entity Framework 4.0,并对与池相关的一些事情感到好奇。 据我所知,连接池由ADO.NET数据提供者管理,在我的情况下是MS SQL服务器。 这是否适用于实例化新实体上下文( ObjectContext )时,即无参数的new MyDatabaseModelEntities() ? a)为应用程序创建全局实体上下文(即一个静态实例)或b)为每个给定的操作/方法创建和展示一个实体上下文,并使用一个using块,有哪些优缺点?

Example of a winforms app implemented as a wpf app?

I'm trying to learn more about WPF and I've read a bit about Model-View-ViewModel (MVVM) but if I were to create a WPF app I think I would still do things, out of habit, the same way I did in winforms. Which from my understand is going to eventually code me into a corner. So to one way for me to learn the 'right' way is to compare and contrast an existing, simple winforms app t

作为wpf应用程序实现的winforms应用程序示例?

我想了解更多关于WPF的知识,我已经阅读了一些关于Model-View-ViewModel(MVVM)的内容,但是如果我要创建一个WPF应用程序,我想我仍然会做一些事情,出于习惯,就像我一样在winforms中做到了。 从我的理解中,最终将我编码到一个角落。 因此,要我学习“正确”方法的一种方式是比较和对比现有的简单的winforms应用程序,该应用程序也是(正确)在wpf中实现的。 我不想找任何复杂的东西,也许只是一些表格和一些控件。 有没