How can I deep clone an entity and avoid errors caused by navigation properties?

The navigation properties on my entity are causing my deep clone to fail with the error: "An object with the same key already exists in the ObjectStateManager" Background: Users want to be able to clone a parent record and all its associated child records. I'm able to clone the parent entity alone (with no errors) using this simple technique: _context.Detach(currentParentEnt

如何深入克隆实体并避免导航属性导致的错误?

我的实体上的导航属性导致我的深层克隆失败并显示错误: “ObjectStateManager中已存在具有相同键的对象” 背景: 用户希望能够克隆父记录及其所有关联的子记录。 我能够使用这种简单的技术单独克隆父实体(没有错误): _context.Detach(currentParentEntity); _context.AddToParentEntities(currentParentEntity); _context.SaveChanges(); 我在这里找到了解决方案和另一种工作浅层克隆技术(来自diamandiev)。 由于

Important data structures in search

I'm interested in teaching myself different data structures, something I currently know very little about. My plan is to implement a few key structures so I understand how they work. I'm looking for suggestions on important data structures to start with. I'm primarily interested in data structures that are relevant to search applications (eg Google / Lucene) and the general trade-

搜索中的重要数据结构

我有兴趣自学不同的数据结构,这是我目前所知甚少的。 我的计划是实施一些关键结构,以便了解它们的工作方式。 我正在寻找关于重要数据结构的建议。 我主要关注与搜索应用程序(例如Google / Lucene)相关的数据结构以及延迟计算和预计算之间的一般折衷。 我还对分布式数据结构感兴趣 - 可以扩展到数百/数千台服务器的数据结构 - 以及概率数据结构 - 有助于找到近似答案的数据结构,但不一定总是正确的。 维基百科有一个

Is StringBuilder.Replace() more efficient than String.Replace?

If you have to use String.Replace() to replace test 50 times, you essentially have to create a new string 50 times. Does StringBuilder.Replace() do this more efficiently? Eg, should I use a StringBuilder if I'm going to be replacing a lot of text, even while I won't be appending any data to it? I'm using .NET, but I assume this would be the same as Java and possibly other language

StringBuilder.Replace()比String.Replace更有效吗?

如果必须使用String.Replace()替换50次测试,则必须创建一个新的字符串50次。 StringBuilder.Replace()是否更有效地执行此操作? 例如,如果我要替换大量文本,是否应该使用StringBuilder,即使我不会向其添加任何数据? 我使用的是.NET,但我认为这将与Java以及其他语言相同。 这正是StringBuilder所用的类型 - 对同一文本对象的重复修改 - 不仅仅是重复连接,尽管这似乎是最常用的。 这取决于替换的大小是否大于替换

ElasticSearch.Net dll quarantine from Antivirus

Symantec Antivirus quarantines the ElasticSearch.Net dll and brings the web application down as access denied error is raised. ElasticSearch.NET Version : 2.3.1 Symantec Version : 12.1.6 I have added in exceptions however I need to know why elasticsearch dlls are quarantined. You can report this false positive to Symantec to have it properly resolved: https://submit.symantec.com/false_p

ElasticSearch.Net将从Antivirus隔离

赛门铁克防病毒隔离了ElasticSearch.Net dll,并在引发访问被拒绝错误时关闭Web应用程序。 ElasticSearch.NET版本:2.3.1 赛门铁克版本:12.1.6 但我需要知道为什么elasticsearch dll会被隔离。 您可以向赛门铁克报告这一误报,以便妥善解决: https://submit.symantec.com/false_positive/ 如果你确信这个DLL,从隔离区恢复它,并将其列入白名单。 或者您可以从可信服务器重新加载elasticsearch。

Fluent NHibernate table per subclass inheritance mapping

I'm new to NHibernate and Fluent NHibernate. I'm wondering how to properly use Fluent NHibernate with the "table per subclass" mapping strategy. This is an example of what I'm after. More specifically though, I need a way to break the subclass mappings into separate files. Also, when adding records, I need NHibernate to first insert into the parent, then into the child

流利的NHibernate表每个子类的继承映射

我是NHibernate和流利NHibernate的新手。 我想知道如何正确使用Fluent NHibernate和“每个子类的表”映射策略。 这是我之后的一个例子。 更具体而言,我需要一种将子类映射分解为单独文件的方法。 另外,当添加记录时,我需要NHibernate先插入父项,然后插入子项。 以下是我的数据库的简化原型。 人员,图像和项目都应该从实体继承。 实体负责生成主键。 PersonnelId,ImageId和ProjectId都具有引用EntityId的外键。

Running Operation in Excel

I have an Excel spreadsheet and I have a .Net library which does some fairly complex calculcations. The .Net assembly is exposed via COM to the VBA code in Excel. When I call out to the .Net library, the Excel UI thread is getting blocked while the calculation is in progress. This prevents the user from interacting with Excel and in some cases indicates to the user that Excel is (Not Respond

在Excel中运行操作

我有一个Excel电子表格,我有一个.Net库,可以进行一些相当复杂的计算。 .Net程序集通过COM暴露给Excel中的VBA代码。 当我呼叫.Net库时,Excel UI线程在计算过程中被阻塞。 这可以防止用户与Excel进行交互,并且在某些情况下向用户指示标题栏中的Excel为(Not Responding)。 我对Excel 2010中的VBA了解不多,但有什么方法可以在不同的线程中产生对.Net库的调用,并向用户呈现“进行中”对话框? 这是可能的,但可能需要

See the effects of a change in a shared assembly on an upstream application

I've got a group of WCF services that share several assemblies. When one of these assemblies are changed, I'd like to know what the impact is for any of the services that reference them. For example, if I have a class named Foo in my shared assembly and it has a method named DoSomething() , which is called by one or more of the dependent services. For release 1, I assume everything is

查看上游应用程序中共享程序集更改的影响

我有一组共享几个程序集的WCF服务。 当其中一个程序集发生更改时,我想知道对引用它们的任何服务会产生什么影响。 例如,如果我的共享程序集中有一个名为Foo的类,并且它有一个名为DoSomething()的方法,该方法由一个或多个相关服务调用。 对于版本1,我假设一切都改变了,因为没有基线。 对于发行版2,我更改了DoSomething()方法,并且想知道哪些服务/方法受到更改的影响。 我的直觉是,NDepend应该能够提供这些信息,但

Detect indirectly dependent libraries

I did following example project: SubClassLibrary - does not use any other DLL besides the .Net Framework ClassLibrary - this does use SubClassLibrary Main Program - this uses ClassLibrary directly If I run NDepend on the Main Program's solution, it only detects the dependency on "ClassLibrary", but not the dependency on "SubClassLibrary" (via ClassLibrary) When I

检测间接依赖库

我做了下面的示例项目: SubClassLibrary - 除.Net Framework外不使用任何其他DLL ClassLibrary - 这确实使用SubClassLibrary 主程序 - 它直接使用ClassLibrary 如果我在主程序的解决方案上运行NDepend,它只检测对“ClassLibrary”的依赖关系,但不检测对“SubClassLibrary”(通过ClassLibrary)的依赖关系 当我将“ClassLibrary”移动到“Application Assemblies”(在NDepend中的Project Settings中)时,找到依赖关系。

Nested dependency graph (DGML) in visual studio

I need to generate detailed dependency information of a .NET project. Integrated dependency graph is a great tool, it can even generate an XML file called DGML, which can be later opened and navigated. This works great if source code is available during the navigation. Unfortunatelly, I have access to source code only to generate this DGML file (or whatever I need) and must be able to broswe

Visual Studio中的嵌套依赖关系图(DGML)

我需要生成一个.NET项目的详细的依赖信息。 集成依赖关系图是一个很好的工具,它甚至可以生成一个名为DGML的XML文件,以后可以打开和导航。 如果源代码在导航过程中可用,这很有用。 不幸的是,我只能访问源代码来生成这个DGML文件(或任何我需要的),并且必须能够离线浏览它,而无需访问源代码。 是否可以为解决方案生成详细的嵌套DGML文件,并且能够根据需要进行深层导航? 我只能对这个图表或单个节点的一个级别进行

What are the best practices for using Assembly Attributes?

I have a solution with multiple project. I am trying to optimize AssemblyInfo.cs files by linking one solution wide assembly info file. What are the best practices for doing this? Which attributes should be in solution wide file and which are project/assembly specific? Edit: If you are interested there is a follow up question What are differences between AssemblyVersion, AssemblyFileVersion

什么是使用Assembly Attributes的最佳实践?

我有多个项目的解决方案。 我试图通过链接一个解决方案宽的程序集信息文件来优化AssemblyInfo.cs文件。 这样做的最佳做法是什么? 哪些属性应该在解决方案的宽文件中,哪些属于项目/程序集特定的? 编辑:如果你有兴趣有一个后续问题AssemblyVersion,AssemblyFileVersion和AssemblyInformationalVersion之间有什么区别? 我们使用名为GlobalAssemblyInfo.cs的全局文件和名为AssemblyInfo.cs的本地文件。 全局文件包含以