草庐IT

image_to_string

全部标签

c# - EF5 ObjectContext : How to replace IQueryable<T>. 包含(路径)与 context.T.Attach()

我在相对较大且复杂的数据模型上使用EntityFramework5和ObjectContext。我想解决将多个IQueryable.Include(Path)链接到急切加载相关对象时生成的大查询。例如,我正在做这样的事情:varqueryPe=context.Person.Where(p=>p.Id==110).Include(@"AA");queryPe=queryPe.Include(@"BB.CC.DD");queryPe=queryPe.Include(@"EE.FF");它可以通过使用字符串数组并在运行时在foreach循环中链接每个图来使其通用。相反,我想做这样的事情:Pe

c# - 神经网络 : why does my function return different outputs to the in-built one?

我正在使用NeuronDotNet用于C#中的神经网络。为了测试网络(以及训练网络),我编写了自己的函数来获取误差平方和。然而,当我通过在训练数据上运行它来测试这个函数并将它与反向传播网络的MeanSquaredError进行比较时,结果是不同的。我发现出现不同错误的原因是当我在学习阶段运行时网络返回不同的输出。我使用以下方法为每个TrainingSample运行它:double[]output=xorNetwork.Run(sample.InputVector);在学习阶段使用:xorNetwork.Learn(trainingSet,cycles);...使用委托(delegate

c# - 错误 : Native images generated against multiple versions of assembly System.Net.Http.Primitives

我在我的WP8.1应用程序中遇到了这个错误,Application_UnhandledExceptionERROR:NativeimagesgeneratedagainstmultipleversionsofassemblySystem.Net.Http.Primitives.atCoolEditor.Class.DropNetRt.DropNetClient.LoadClient()atCoolEditor.Class.DropNetRt.DropNetClient..ctor(StringapiKey,StringappSecret)atCoolEditor.MainPage.d_

c# - DI Framework : how to avoid continually passing injected dependencies up the chain, 且未使用服务定位器(特别是使用 Ninject)

我需要更多帮助才能“了解”像Ninject这样的DI框架如何超越基础知识。以Ninject为例:classSamurai{privateIWeapon_weapon;[Inject]publicSamurai(IWeaponweapon){_weapon=weapon;}publicvoidAttack(stringtarget){_weapon.Hit(target);}}如果没有DI框架(即上面的[Inject]引用),引用类将类似于:classProgram{publicstaticvoidMain(){Samuraiwarrior1=newSamurai(newShuriken

c# - .NET 自定义配置部分 : Configuration. GetSection 引发 'unable to locate assembly' 异常

我已经为一个插件DLL创建了一个自定义配置部分,它将.configXML存储在一个单独的(与主可执行应用程序不同的)文件中。这是自定义部分类的示例:usingSystem;usingSystem.Configuration;namespacePluginFramework.MyConfiguration{publicclassMyConfigurationSettings:ConfigurationSection{privateConfiguration_Config=null;#regionConfigurationProperties//////AcustomXMLsectionf

c# - 如何强制 LINQ to SQL 评估数据库中的整个查询?

我有一个完全可翻译成SQL的查询。由于未知原因,LINQ决定最后一个Select()在.NET中执行(而不是在数据库中),这导致对数据库运行大量额外的SQL查询(每个项目)。实际上,我发现了一种“奇怪”的方法来强制将完整翻译成SQL:我有一个查询(这是一个非常简化的版本,仍然没有按预期工作):MainCategories.Select(e=>new{PlacementId=e.CatalogPlacementId,Translation=Translations.Select(t=>new{Name=t.Name,//...}).FirstOrDefault()})它会产生大量的SQL

c# - 由文化敏感的 String.IndexOf 方法匹配的子字符串的长度

我尝试编写一个文化感知字符串替换方法:publicstaticstringReplace(stringtext,stringoldValue,stringnewValue){intindex=text.IndexOf(oldValue,StringComparison.CurrentCulture);returnindex>=0?text.Substring(0,index)+newValue+text.Substring(index+oldValue.Length):text;}但是,它会在Unicode组合字符时阻塞://\u0301isCombiningAcuteAccentCo

c# - Linq to SQL 计数分组元素生成超时

我有一个看起来像这样的表:FruitID|FruitType23|2215|2256|1643|3我想通过FruitType获得一个名为TheFruitIDs的FruitIDs列表。这是我的:varTheCounter=(fromfinMyDC.FruitswhereTheFruitIDs.Contains(f.FruitID)groupfby0intoTheFruitsselectnewMyCounterMode(){CountType1=(int?)TheFruits.Where(f=>f.FruitType==1).Count()??0,CountType2=(int?)TheF

c# - TcpListener : how to stop listening while awaiting AcceptTcpClientAsync()?

我不知道如何在异步方法等待传入连接时正确关闭TcpListener。我在SO上找到了这段代码,这里是代码:publicclassServer{privateTcpListener_Server;privatebool_Active;publicServer(){_Server=newTcpListener(IPAddress.Any,5555);}publicasyncvoidStartListening(){_Active=true;_Server.Start();awaitAcceptConnections();}publicvoidStopListening(){_Active=

c# string[] 与 IEnumerable<string>

如果我在运行前就知道元素的数量,我应该选择什么?Resharper为我提供IEnumerable而不是string[]? 最佳答案 ReSharper建议IEnumerable如果您只使用为IEnumerable定义的方法。它这样做的想法是,由于您显然不需要将值键入为数组,因此您可能希望对消费者(即使用的代码)隐藏确切的类型值,因为您将来可能想更改类型。在大多数情况下,采纳建议是正确的做法。差异将不是您在程序运行时可以观察到的东西;相反,它取决于您将来对程序进行更改的难易程度。从上面你也可以推断出整个建议/问题是没有意义的,除非我们