草庐IT

doctrine-collection

全部标签

c# - 为什么此 XAML 收到错误 : Items collection must be empty before using ItemsSource

任何人都可以从这段代码中联想到为什么ItemsSource行会得到一个ItemscollectionmustbeemptybeforeusingItemsSource.错误?我发现的大多数解决方案都指向错误组合的XAML,例如我似乎没有的额外元素等。当我拿出来的时候ItemsSource="{BindingCustomers}"它运行没有错误(但当然不会显示我的客户列表)。Customers在ViewModel中这样定义,其中有3个CustomerViewModels:Customer[]customers=Customer.GetCustomers();IEnumerablecust

c# - WPF 数据网格 : DataGridComboxBox ItemsSource Binding to a Collection of Collections

情况:我在XAML中创建了一个DataGrid,并且ItemsSource绑定(bind)到包含属性的特定类的ObservableCollection。然后在C#中,我创建了一个DataGridTextColumn和一个DataGridComboBoxColumn,并将它们绑定(bind)到ObservableCollection中对象的属性。我可以将DataGridComboBoxColumn绑定(bind)到一个简单的Collection,但我想要做的是将它绑定(bind)到一个字符串集合的集合,这样对于每一行,DataGrid中的ComboBox都有一个不同的字符串集合。我没有这

c# - "Items collection cannot be modified when the DataSource property is set."

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭11年前。通过表单将文件添加到txt文件的程序有这个问题,但这个问题没有说明Fstream的任何内容,所以我认为它不必处理它,但我不确定是什么这个问题的意思是。lstEmployees.Items.Add("Norecordsfound.");

C# GC.Collect 如果对象是使用实例构造函数初始值设定项构造的,则不会销毁该对象

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:ResurrectiondifferenceinusingObjectInitializer我很难理解垃圾收集器在C#中的工作原理(我使用的是2012,所以是c#4.5)。这是我的示例代码:publicclassA{publicintc;publicA(){}publicA(intpC){c=pC;}}publicstaticvoidMain(){//Test1vara=newA{c=199};varaRef=newWeakReference(a);a=null;Console.WriteLine(aRef.I

c# - System.Collections.Generic.List<T> 需要 '1' 类型参数

我在以下代码中遇到此错误:string[]colors={"green","brown","blue","red"};varlist=newList(colors);IEnumerablequery=list.Where(c=>c.length==3);list.Remove("red");Console.WriteLine(query.Count());此外,Count()似乎不再被允许。它被弃用了吗? 最佳答案 您正在尝试创建一个List你应该告诉编译器varlist=newList(colors);没有List,有一个名为Li

c# - 奇怪的 "Collection was modified after the enumerator was instantiated"异常

也许有人可以为我指出正确的方向,因为我对此一头雾水。我有一个函数可以简单地打印出类的LinkedList:LinkedListcomponents=newLinkedList();...privatevoidPrintComponentList(){Console.WriteLine("---ComponentList:"+components.Count+"entries---");foreach(Componentcincomponents){Console.WriteLine(c);}Console.WriteLine("------");}Component对象实际上有一个自定

c# - 避免 InvalidOperationException : Collection was modified? 的最佳实践

我经常需要这样的东西:foreach(Linelineinlines){if(line.FullfilsCertainConditions()){lines.Remove(line)}}这不起作用,因为我总是得到一个InvalidOperationException,因为Enumerator在循环期间被更改了。所以我将所有此类循环更改为以下内容:Listremove=newList();foreach(Linelineinlines){if(line.FullfilsCertainConditions()){remove.Add(line)}}foreach(Linelineinrem

c# - "Collection was of a fixed size"带有 POCO 的 EF4 异常

我将EF4与WCF和POCO结合使用。我删除了POCO实体中的所有虚拟关键字。我有Employee和Team实体,两者之间的关系是1:N,意味着一名员工只能分配到一个团队。我想在现有团队中添加新员工。以下代码在客户端。privatevoidbtnAdd_Click(objectsender,RoutedEventArgse){TeamteamFromDb=ServiceProxy.GetService.GetTeamById(181);EmployeenewEmp=newEmployee{UserName="username"};newEmp.Team=teamFromDb;Servi

c# - DDD : entity's collection and repositories

假设我有publicclassProduct:Entity{publicIListItems{get;set;}}假设我想找到一个最大的项目...我可以添加方法Product.GetMaxItemSmth()并使用Linq(fromiinItemsselecti.smth).Max())或使用手动循环或其他方式。现在,问题是这会将整个集合加载到内存中。正确的解决方案是进行特定的数据库查询,但域实体无权访问存储库,对吧?所以要么我做productRepository.GetMaxItemSmth(product)(这很丑,不是吗?),或者即使实体可以访问存储库,我也使用来自实体的IPro

c# - System.Collections.Generic.List 中的某项在什么情况下不会被删除成功?

在什么情况下System.Collections.Generic.List中的item不会被成功移除?来自http://msdn.microsoft.com/en-us/library/cd666k3e.aspx:trueifitemissuccessfullyremoved;otherwise,false.ThismethodalsoreturnsfalseifitemwasnotfoundintheList(OfT).他们表达它的方式让我认为对List(OfT)中找到的项目的删除操作实际上可能会失败,因此这个问题。 最佳答案 查