草庐IT

graphql_collections

全部标签

c# - 'System.Collections.Generic.List<float >' does not contain a definition for ' Sum'

我正在尝试使用内置的Sum()函数对float列表求和,但我不断收到此错误:ErrorCS1061:'System.Collections.Generic.List'doesnotcontainadefinitionfor'Sum'andnoextensionmethod'Sum'acceptingafirstargumentoftype'System.Collections.Generic.List'couldbefound(areyoumissingausingdirectiveoranassemblyreference?)(CS1061)我有usingSystem.Collect

python中的deque模块(collections的deque模块)

目录1.deque是python的collections中的一个类2.deque的简单使用以及它的方法2.1创建deque的方法 2.2创建deque时,并指定大小maxlen,即能装几个元素,以及deque添加元素append()方法2.3 deque的 appendleft()方法2.4 deque的clear()方法2.5 deque的copy()方法2.6deque的count方法2.7deque中的extend()方法2.8 deque中的extendleft()方法2.9deque中的index方法2.10deque中的insert方法2.11deque中的pop方法2.12deq

c# - EF 4.1 和 "Collection was modified; enumeration operation may not execute."异常

在过去的2天里,这让我抓狂。我有3个非常基本的类(好吧,为了便于阅读而减少了)publicclassEmployee{publicstringName{set;get;}virtualpublicEmployerEmployer{set;get;}publicEmployee(stringname){this.Name=name;}},//thisbasicallytiesEmployeeandhisroleinacompany.publicclassEmployeeRole{publicintId{set;get;}virtualpublicEmployeeEmployee{set;

c# - “不要公开通用列表”,为什么在方法参数中使用 collection<T> 而不是 list<T>

我正在使用FxCop,它显示“不要公开通用列表”的警告,建议使用Collection而不是List.首选它的原因,我知道所有这些东西,如thisSOpost中所述和MSDN以及我浏览过的更多文章。但我的问题是,我很少有方法可以进行如此繁重的计算,并且方法接受List的参数。就性能而言,这应该更快更好。但是FxCop也为此发出警告。所以一个选择是我应该将参数声明为Collection,然后使用ToList()在方法内部,然后使用它。那么优化了哪一个呢?“抑制这种情况下的警告”或“在参数中使用Collection,然后在方法本身内部使用ToList()”。 最佳

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# 找不到类型或命名空间名称 `List'。但我正在导入 System.Collections.Generic;

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

c# - GraphQL 为 .net 开发做好准备

我发现GraphQL是一种诱人的选择,可以将前端开发与API分离(可能非常适合我们公司,该公司为每个客户进行大量API定制)。但是,我不太清楚它是否已准备好用于.NET开发环境,或者它是否仍被视为一项早期技术?我也不知道它背后是否有更大的问题(例如N+1问题)。在.NET实现中对GraphQL有任何经验和指导吗? 最佳答案 一个月后这里没有答案这一事实应该说明了它的故事。我已将关注点从.NETFramework转移到.NETCore,在试用了可用的.NET库后,我很快就选择了基于TypeScript构建的API网关和更成熟的Face

C#语言 : Garbage Collection, SuppressFinalize

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

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,域对象不应该知道数据上下文,因此必须在域外进行删除。解决这个问题的正确方法是什么?或者让数据库中充满孤儿是可以接受的吗(也许运行一个例程来清除它们)?