草庐IT

String_to_be_returned

全部标签

c# - LINQ to Entities 查询不支持转换为十进制

我有一个数据库表Transaction(transactionID,LocalAmount...)。其中Localamount属性的数据类型是float。在UI上,我试图在按钮单击事件的一行中返回列(Localamount)的SUM。我使用了decimal而不是float但是,我在转换为decimal的代码中遇到错误System.NotSupportedExceptionwasunhandledbyusercodeMessage=CastingtoDecimalisnotsupportedinLINQtoEntitiesqueries,becausetherequiredprecisi

c# - Azure 通知中心。 GetRegistrationsByTagAsync(string tag, int top) 的第二个参数代表什么?

documentation在Azure推送通知中说明NotificationHubClient.GetRegistrationsByTagAsync(stringtag,inttop),如下所示,top(Int32):Thelocationwheretogettheregistrations.但我不知道top或location代表什么。Anexample我发现只使用100但没有理由使用它。 最佳答案 基本上这意味着最多获得top记录。因此,如果您有1000个带有标签“A”的注册,则NotificationHubClient.GetR

c# - JWT 错误 IDX10634 : Unable to create the SignatureProvider C#

我正在尝试运行我的应用程序,但它因以下错误而卡住:System.NotSupportedExceptionHResult=0x80131515Message=IDX10634:UnabletocreatetheSignatureProvider.Algorithm:'[PIIishiddenbydefault.Setthe'ShowPII'flaginIdentityModelEventSource.cstotruetorevealit.]',SecurityKey:'[PIIishiddenbydefault.Setthe'ShowPII'flaginIdentityModelEve

c# - 错误 : The object cannot be deleted because it was not found in the ObjectStateManager

试图在这里处理EntityFramework,但我遇到了一些减速带......我有一个Get()方法可以正常工作并且已经过测试,但是我的Delete方法不起作用:publicstaticvoidDelete(stringname){J1Entitiesdb=newJ1Entities();db.DeleteObject(Get(name));db.SaveChanges();}但是我收到以下错误:错误:无法删除该对象,因为在ObjectStateManager中找不到它。我运行了调试器,DeleteObject中的对象是正确的...我错过了什么?谢谢。 最佳

c# - String.Format 计算预期参数的数量

是否可以计算String.Format()字符串中预期参数/参数的数量?例如:“你好{0}。再见{1}”应该返回计数2。我需要在string.Format()抛出异常之前显示错误。感谢您的帮助。 最佳答案 您可以使用正则表达式,例如{(.*?)}然后只计算匹配项。如果您需要处理{0}{0}之类的情况(我想应该返回1),那么这会变得有点困难,但是您总是可以将所有匹配项放在一个列表中,然后在其上执行Linqselectdistinct.我在想类似下面的代码:varinput="{0}and{1}and{0}and{2:MM-dd-yyy

c# - Visual Studio 2015 中是否有用于 C# 的 "Go To Variable Type Declaration"函数或一个免费插件?

voidMagicalFunction(MagicalTypemagic){...magic.Poof("something");...varfoo=magic.GetFoo();...}在变量magic上按下热键将导航到类型MagicalType的定义。在foo上按下热键将转到类型Foo的定义,由于类型推断,它在这里不直接可见。Resharper插件具有此功能(称为GoToTypeofSymbol),但是是否有内置的替代方案或免费扩展来执行此操作? 最佳答案 右键单击“var”关键字,从上下文菜单中选择“Gotodefinitio

c# - 语法 : return _(); IEnumerable<TSource> _() 的含义

这个问题在这里已经有了答案:Oddreturnsyntaxstatement(2个答案)关闭5年前。在下面的C#代码中,我发现_()的用法很奇怪。谁能解释一下这是什么意思?publicstaticIEnumerableDistinctBy(thisIEnumerablesource,FunckeySelector,IEqualityComparercomparer){if(source==null)thrownewArgumentNullException(nameof(source));if(keySelector==null)thrownewArgumentNullExceptio

c# - "The format of the URI could not be determined"与 WebRequest

我正在尝试使用C#中的WebRequest对站点执行POST。我发布到的站点是一个SMS站点,消息文本是URL的一部分。为了避免URL中出现空格,我调用HttpUtility.Encode()对其进行URL编码。但我不断收到URIFormatException-“无效的URI:无法确定URI的格式”-当我使用类似于此的代码时:stringurl="http://www.stackoverflow.com?question=asentencewithspaces";stringencoded=HttpUtility.UrlEncode(url);WebRequestr=WebReques

c# - 如何为 string.Format 设置命名参数?

调用时出现C#错误:string.Format(format:"abbccc",1,22);错误是“命名参数规范必须在指定所有固定参数后出现”我该如何解决这个问题?[编辑]我更喜欢使用命名参数。 最佳答案 如果要指定格式参数的名称,还必须指定以下参数的名称:string.Format(format:"abbccc",arg0:1,arg1:22);这不是很有用,因为名称“arg0”和“arg1”根本没有说明参数。另外,只有到“arg2”的重载,所以如果你有更多的参数,你必须把它们放在一个数组中来命名参数:string.Format(

c# - 在 Linq-To-Sql 中避免 "Nullable object must have a value."

我有一个这样的方法查询:publicIListGetBusinessObject(Guid?filterId){using(vardb=newL2SDataContext()){varresult=fromboindb.BusinessObjectswhere(filterId.HasValue)?bo.Filter==filterId.value:trueorderbybo.NameselectSqlModelConverters.ConvertBusinessObject(bo);returnresult.ToList();}}在运行时,这会抛出一个System.InvalidOp