草庐IT

collection_names

全部标签

c# - 在 WPF 中获取 "<Property Name> was already registered by "<控件名称>"错误

我在WPF中有一个用户控件,它绑定(bind)到一个依赖属性。当我尝试编译应用程序时,出现“属性名称”已由“控件名称”注册的错误,设计器显示“无法创建“用户控件”的实例”错误。这是我的简单控件的样子:ExampleUserControl.xaml:ExampleUserControl.xaml.cs:publicpartialclassExampleUserControl:UserControl{publicDependencyPropertySomeStringValueProperty=DependencyProperty.Register("SomeStringValue",ty

c# - 错误 : Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

我正在尝试使用该控件从.ascx设置我的.ascx控件的属性。所以在我的一个包含此控件的.aspx中,我有以下代码试图设置我的嵌入式.ascx的ItemsList属性:Itemitem=GetItem(itemID);myUsercontrol.ItemList=newList().Add(item);我尝试设置的.ascx中的属性如下所示:publicListItemsList{get{returnthis.itemsList;}set{this.itemsList=value;}}错误:无法将类型“void”隐式转换为“System.Collections.Generic.List

c# - 可以找到 Entity Framework 迁移 "No connection string named ' DefaultConnection ......”

过去几个月我一直在使用MVC5和EntityFramework6。我已将我的主要模型/业务逻辑和“迁移”分离到一个单独的程序集,并在我的Web应用程序中引用它。迁移一直运行良好。今天我运行“更新数据库”,我得到“在应用程序配置文件中找不到名为‘DefaultConnection’的连接字符串。”“DefaultConnection”仍在我的web.config文件中。如果我将该部分复制到迁移所在的项目,它将再次运行。如果我删除该部分,它会抛出该错误。我不知道可能发生了什么变化。从昨天开始我唯一做的就是运行“磁盘清理”来清理我硬盘​​上的空间。 最佳答案

C# 找不到类型或命名空间名称 `List'。但我正在导入 System.Collections.Generic;

我有一个错误Thetypeornamespacename`List'couldnotbefound.Areyoumissingausingdirectiveoranassemblyreference?示例代码:usingUnityEngine;usingSystem.Collections;usingSystem.Collections.Generic;publicclasscity1:MonoBehaviour{publicstaticListitems=newList();publicstaticListitemsprice=newList();publicstaticListqu

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

C#语言 : Garbage Collection, SuppressFinalize

我正在阅读“TheC#Language”,第4版,它讨论垃圾收集如下:"BILLWAGNER:ThefollowingruleisanimportantdifferencebetweenC#andothermanagedenvironments.Priortoanapplication’stermination,destructor'sforallofitsobjectsthathavenotyetbeengarbagecollectedarecalled,unlesssuchcleanuphasbeensuppressed(byacalltothelibrarymethodGC.Su

c# - 属性 'name'是对象关键信息的一部分,不能修改。 Entity Framework

我正在尝试更新记录,但在context.SaveChanges();之后收到此错误消息Theproperty'name'ispartoftheobject'skeyinformationandcannotbemodified.这是更新函数的代码:if(context.EAT_SourceNames.Any(e=>e.name==newSourceName)){MessageBox.Show("NamealreadyexistsintheDatabase");}else{varnameToUpdate=context.EAT_SourceNames.SingleOrDefault(e=>

c# - 内部 System.Linq.Set<T> 与公共(public) System.Collections.Generic.HashSet<T>

检查Linq.Enumerable类中的这段代码:staticIEnumerableDistinctIterator(IEnumerablesource,IEqualityComparercomparer){Setset=newSet(comparer);foreach(TSourceelementinsource)if(set.Add(element))yieldreturnelement;}为什么Microsoft的人决定使用Set的这个内部实现而不是常规的HashSet?如果它在任何方面都更好,为什么不向公众公开呢? 最佳答案

c# - EF 代码首先是 : How to delete a row from an entity's Collection while following DDD?

场景是这样的:DDD声明您使用存储库获取聚合根,然后使用它来添加/删除它拥有的任何集合。添加很简单,您只需在要添加到的Collection上调用.Add(Itemitem)。保存时会向数据库中添加一个新行。但是,删除是不同的-调用.Remove(Itemitem)不会从数据库中删除项目,它只是删除外键。因此,是的,从技术上讲,它不再是收藏的一部分,但它仍在数据库中。仔细阅读,唯一的解决方案是使用数据上下文将其删除。但是根据DDD,域对象不应该知道数据上下文,因此必须在域外进行删除。解决这个问题的正确方法是什么?或者让数据库中充满孤儿是可以接受的吗(也许运行一个例程来清除它们)?

javascript - Backbone : How to update a collection view when collection changes?

我对Backbone.js比较陌生。我正在初始化一个CollectionView并在创建时传入一个集合。suggestionsView=newTreeCategoriesAutoSuggest.Views.Suggestions({collection:newApp.Collections.Suggestions(this.getSuggestions(query))});然后我渲染CollectionView。每次用户在文本框中输入查询时,都会重新生成集合并使用以下方法将其分配给CollectionView:suggestionsView.collection.set(this.ge