草庐IT

stream_resolve_include_path

全部标签

c# - UnityContainer.Resolve 还是 ServiceLocator.GetInstance?

这似乎是一个愚蠢的问题,因为在我的代码中一切正常,但我已经用我的Unity容器_ambientContainer以这种方式注册了一个单例:_ambientContainer.RegisterType(newContainerControlledLifetimeManager());为了避免使用我的本地字段,我使用:get{returnServiceLocator.Current.GetInstance();}在我的get属性中获取我的对象的一个​​实例。这样我总是得到相同的实例(Application.StateContext仍然是一个单例)或者GetInstance创建一个新实例?使

c# - "Include in Project"Visual Studio 2013 中数据集的异常行为

我想做一件非常简单的事情:将VS13中的一些代码从一个项目移到另一个项目中,我正面临数据集的奇怪问题。为简单起见,假设在我的源项目中我有一个名为MyDataSet的数据集,它由5个文件组成:MyDataSet.cs、MyDataSet.Designer.cs、MyDataSet.xsc、MyDataSet.xsd、MyDataSet.xss。然后我使用标准Windows功能将这些文件复制到我的目标项目文件夹,并使用VS13中的IncludeinProject菜单选项。之后我看到添加了一个额外的文件:MyDataSet1.Designer.cs。我试图检查cproj文件,它们是不同的。来

c# - ASP.NET Core RC2 项目引用 "The Dependency X could not be resolved"

概览我有一个ASP.NETCoreRC2.NET框架Web项目,我想添加对同一解决方案中包含的常规C#类库的项目引用。重现步骤:使用VisualStudio2015更新2文件->新建项目->ASP.NETCoreWeb应用程序(.NETFramework)右键解决方案->新建项目->类库我不会做这些:类库(.NETCore)类库(适用于iOS、Android和Windows)类库(可移植)将以下内容添加到project.json中的dependencies中:"ClassLibrary1":{"version":"*","target":"project"}问题为什么在指定项目依赖项时

c# - Entity Framework 中多个 "Include"-s 的最佳实践是什么?

假设我们在数据模型中有四个实体:Categories、Books、Authors和BookPages。还假设Categories-Books、Books-Authors和Books-BookPages关系是一对多的。如果从数据库中检索类别实体实例——包括“Books”、“Books.BookPages”和“Books.Authors”——这将成为一个严重的性能问题。此外,不包括它们将导致“对象引用未设置为对象的实例”异常。使用多个Include方法调用的最佳实践是什么?编写单个方法GetCategoryById并将所有项目包含在其中(性能问题)编写单个方法GetCategoryById

c# - 在 Entity Framework 中使用 include 语句时选择特定列

当我需要分层(父子)关系时,我通常在我的EF查询中使用Include语句。例子:DbContext.Customers.Include("Projects");这很好,但是Customers和Projects实体总是会带回所有列。我知道下面的查询将返回父表中的特定列,但我也试图仅返回子表中的特定列。如果我在Projects上使用intellisense,它显然是一个集合,不会提供特定的属性供选择。fromcinCustomersletProjects=c.Projects.Where(p=>p.Notes!=null)whereProjects.Any()selectnew{c.Use

c# - 在 Directory.GetFiles 中使用通配符时出现 "Illegal characters in path"错误

我有一个包含多个包含.doc文件的子目录的目录。示例:C:\Users\user\Documents\testenviroment\Released\test0.docC:\Users\user\Documents\testenviroment\Debug\test1.docC:\Users\user\Documents1\testenviroment\Debug\test2.docC:\Users\user\Documents1\testenviroment\Released\test20.doc我想获取所有Debug文件夹下的所有test*.doc文件。我试过:string[]fi

c# - T4 模板错误 : loading the include file ef. utility.cs.ttinclude 返回了 null 或空字符串

我已经覆盖了Controller生成T4模板(ControllerWithContext.tt),如here所述.我想利用在POCO模型生成器T4模板中使用的EF.utility.CS.ttinclude中的代码帮助实用程序。因此,我将以下行从我的Model.tt复制到我的ControllerWithContext.tt。但是,当我尝试添加Controller时,我收到了错误消息Loadingtheincludefile'EF.utility.CS.ttinclude'returnedanulloremptystring根据MSDNdocumentation,这个错误是因为包含的文件是

c# - LINQ To Entities Include + Where 方法

我有NxN表,想象一下:User(id,...)地址(id,...)UserAddresses包含用户和地址的外键。据我所知,EntityFramework用户创建的实体包含一个UserAddresses集合。Address包含UserAddresses的集合,一个特定的UserAddress包含对User和一个Address的引用。现在我想通过linq进行下一个查询。对于特定的用户ID,仅获取启用标志设置为true的userAddresses。对于特定的用户ID,userAddresses可以包含多个条目,但仅为该特定用户设置一个。我可以做的查询是:context.User.Incl

c# - System.Net.ProtocolViolationException : You must write ContentLength bytes to the request stream before calling [Begin]GetResponse

我得到了"System.Net.ProtocolViolationException:YoumustwriteContentLengthbytestotherequeststreambeforecalling[Begin]GetResponse"errorwhencallingtothe"BeginGetResponse"methodofthewebrequest.这是我的代码:try{StreamdataStream=null;WebRequestWebrequest;Webrequest=WebRequest.Create(this.EndPointAddress);Webrequ

c# - asp.net 中 ./, ../, ../../, ~/on file path(URL) 之间的区别

我有一个脚本文件。看到路径是~/Script。但是,如果我输入../../而不是~/,该过程也同样有效。我的网站URL如:https://sample.com/Scripts/angular.js如果我在Scripts之前输入../../,那么它会自动更改以前的URL(https://sample.com/Scripts/angular.js).Whatistheurlprocess?Andhowcanitsautomaticallychanged?andpleasetellabouttheDifferentbetween./,../,../../,~/,/Scripts,Script