草庐IT

data-index

全部标签

c# - 如何使用 Active Directory 通用身份验证打开 System.Data.SQLClient.SQLConnection

我使用以下代码连接到使用ActiveDirectory集成身份验证的SQLAzure数据库。privatestringGenerateConnectionString(stringdatabaseName,stringserverName){SqlConnectionStringBuilderconnBuilder=newSqlConnectionStringBuilder();sqlConnectionBuilder.DataSource=string.Format("tcp:{0}.database.windows.net",serverName);connBuilder.Init

c# - 实验性特征 "indexed members"是什么?

论新RoslynPreviewsite它提到能够尝试潜在的语言特性,并列出了三个这样的特性。前两个我以前听说过(例如here),但我无法从代码示例中弄清楚“索引成员”是什么。谁能根据其他来源或代码示例解释这些是什么?(毫无值(value)$x不是C#5中的有效标识符。)更新-根据RoslynFeatureStatus页面,此功能已被撤销。 最佳答案 .$foobar只是["foobar"]的缩写形式 关于c#-实验性特征"indexedmembers"是什么?,我们在StackOverf

c# - 设计 : How to inform controllers about data modification across application

在基于mvc的大型系统中,有负责编辑数据的View和显示该数据的View。示例:UserManagementView和UserSelectionView.每个子系统都应该知道自己是否需要更新数据,在另一个子系统对相同数据进行更改后,以便其Controller知道是否需要更新数据。我对此的想法有点像观察者模式(有点集成在c#中),所有Controller都将成为监听器,并最终会收到发生数据操纵的通知。BindingList例如提供ListChanged事件。同样,可以为每个数据结构创建一个接口(interface),并将更改通知Controller。这会增加开销(IMO),而且我发现这种

c# - ASP.NET Core 中的 System.Data.Entity.Spatial 替换

我正在尝试将Web表单从ASP.NETMVC迁移到ASP.NETCoreMVC。目前我正在尝试找到一种方法来替换:usingSystem.Data.Entity.Spatial;因为它目前在.NETCore中不可用,或者我可能找不到它。有没有办法包含这个包?也许通过NuGet包?附言。我简要阅读了Microsoft指南,但找不到与之相关的任何内容。对于任何可能处于类似情况的人,指南在这里:https://docs.asp.net/en/latest/migration/mvc.html(对不起,如果我不能写出一个好问题,我正在努力适应这里的系统) 最佳答案

c# - 使用 HttpWebRequest POST 数据/使用 multipart/form-data 上传图像

我正在尝试使用ImageShackAPI上传图片。要使用它,我应该使用multipart/form-dataPOST图像。我这样做了......varpostData="";varreq=HttpWebRequest.Create("http://www.imageshack.us/upload_api.php");req.Method="POST";req.ContentType="multipart/form-data";postData+="key=my_key_here&";postData+="type=base64&";//getbase64datafromimagebyt

c# - 在 c# Parallel.ForEach 中的 List.Add() 上出现 "Index out of bounds"错误

这是代码Listsomething=newList();Parallel.ForEach(anotherList,r=>{..dosomeworksomething.Add(somedata);});Indexoutofbounds错误大约每百次运行1次。有没有办法防止由线程引起的冲突(我假设)? 最佳答案 为了防止出现此问题,您可以使用ConcurrentQueue而不是List或并行部分中的类似并发集合。并行任务完成后,您可以将其放入List中。.有关详细信息,请查看System.Collections.Concurrent命名

c# - 为什么 Dictionary[index] 会抛出 KeyNotFoundException 但 Hashtable[index] 不会?

知道为什么这种行为不同吗? 最佳答案 这是answer.TheprimaryreasonDictionarythrowsisthatthereisno"error"valuethatworksoveranyV.Hashtableisabletoreturnnullbecausethekeyisalwaysareferencetype. 关于c#-为什么Dictionary[index]会抛出KeyNotFoundException但Hashtable[index]不会?,我们在Stack

c# - 无法从 'System.Data.Objects.ObjectParameter' 转换为 'System.Data.Entity.Core.Objects.ObjectParameter'

在创建ADO.NETEntityDataModel时,出现以下错误:Error66Argument10:cannotconvertfrom'System.Data.Objects.ObjectParameter'to'System.Data.Entity.Core.Objects.ObjectParameter'D:\Aziz\AzizProject\Development\RunningDevelopment\Web\pos\pos\Model1.Context.cs351278pos如何解决这个错误? 最佳答案 usingSys

c# - 如何处理System.Data.Entity.Validation.DbEntityValidationException?

这个问题在这里已经有了答案:Validationfailedforoneormoreentities.See'EntityValidationErrors'propertyformoredetails[duplicate](29个答案)关闭2年前。我的应用出现以下错误:Anexceptionoftype'System.Data.Entity.Validation.DbEntityValidationException'occurredinEntityFramework.dllbutwasnothandledinusercodeAdditionalinformation:Validati

c# - 如何从 C# 提交 multipart/form-data HTTP POST 请求

从C#提交带有multipart/form-data内容类型的HTTPPOST请求的最简单方法是什么?必须有比构建我自己的请求更好的方法。我问的原因是使用此api将照片上传到Flickr:http://www.flickr.com/services/api/upload.api.html 最佳答案 如果您使用的是.NET4.5,请使用:publicstringUpload(stringurl,NameValueCollectionrequestParameters,MemoryStreamfile){varclient=newHtt