草庐IT

dynamic-properties

全部标签

c# - System.Linq.Dynamic 和 DateTime

我正在使用System.Linq.Dynamic在.NetMVC1.0中执行来自ajax调用的自定义where子句。它适用于字符串、整数等,但不适用于DateTime,我得到异常无法将String与DateTime进行比较。非常简单的测试代码是items=items.Where(string.Format(@"{0}>{1}{2}{1}",searchField,delimiter,searchString));例如,searchField是start_date,数据类型是DateTime,分隔符是"(也没有尝试过),searchString是01-Jan-2009(也尝试过01/01

c# - 阻止访问私有(private)成员变量?强制使用公共(public)属性(property)?

我使用的是.NET2.0,因此无法访问自动属性。所以我必须求助于以下编码私有(private)变量和公共(public)属性的方法privatestringm_hello=null;publicstringHello{get{returnm_hello;}set{m_hello=value;}}对于上述private/public成员的包含类的方法,是否有限制访问private变量的方法?我不喜欢我可以使用m_hello或Hello。谢谢。 最佳答案 正如其他人所建议的那样,这应该是一个答案...当面向.NET2.0时,您仍然可以在

c# - 验证错误 : The value 'on' is not valid for <<property name>>

在我的项目中,我有一个模型,您可以在这里看到我模型的一部分:publicclassCheckoutModel{publicboolOtherPlace{get;set;}[RequiredIf("OtherPlace",true,ErrorMessage="")]publicstringOtherPlaceFullName{get;set;}[RequiredIf("OtherPlace",true,ErrorMessage="")]publicintOtherPlaceProvinceId{get;set;}[RequiredIf("OtherPlace",true,ErrorMes

c# - 执行非查询 : Connection property has not been initialized.

下午,所以我已经在这个问题上研究了几个小时,但无法真正克服最后一个障碍。下面是我正在编写的这个程序的代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Diagnostics;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;namespaceTest{classProgram{staticvoidMain(){EventLogalog=newEventLog();

c# - 在 C# 的 Dynamic Linq 中使用 "Contains"关键字查询数据

在C#的动态linq中执行具有“包含”关键字的查询时,我遇到了一些问题。我收到以下错误“Int32”类型中不存在任何属性或字段我的代码如下:如果我为数据类型字符串字段使用“包含”关键字,那么它可以正常工作,如下所示string[]CandidateNamesArray=newstring[]{"Ram","Venkat","Micheal"}vardynamicLinqQuery=Candidates.Where("CandidateName.Contains(@0)",CandidateNamesArray);工作正常但是如果我对数据类型int字段使用“Contains”关键字,那么

c# - CA1819 : Properties shouldn't return arrays - What is the right alternative?

我以前遇到过这个FxCop规则,但对如何解决违规问题并不满意(thread1、thread2)。我现在有另一个案例,我需要纠正违反CA1819的行为亲切。具体来说,我有一个算法库,它使用如下所示的公共(public)“输入对象”对曲线(x,y)执行一些分析计算:publicclassInputObject{publicdouble[]X{get;set;}publicdouble[]Y{get;set;}//+lotsofotherthingswell}此对象的X和Y属性在库中的数百个位置使用,通常使用索引。输入对象永远不会被算法改变,但实际上如果是这样也无关紧要。另外,.Length

c# - ASP.NET MVC3 中的 Razor 和接口(interface)继承 : why can't this property be found?

我在ASP.NETMVC3应用程序中的一个RazorView有一个奇怪的问题。当我将其值写入调试器控制台时,该属性似乎确实存在,但我收到一条错误消息,告诉我无法找到该属性。我的View将一个名为FormEditViewModel的类作为其模型。FormEditViewModel有一个IForm类型的属性,一个继承自另一个接口(interface)IFormObject的接口(interface)。IFormObject定义了一个属性Name,因此任何实现IForm的东西都必须实现一个名为Name的属性。具体类型Form实现接口(interface)IForm并根据需要定义Name属性。

c# - 错误 : An expression tree may not contain a dynamic operation

我使用Asp.Net4和C#,我使用EF4。我有这个查询,我收到一个错误:Anexpressiontreemaynotcontainadynamicoperationdynamico=e.Item.DataItem;varimagesContent=context.CmsImagesContents.FirstOrDefault(img=>img.ContentId==o.ContentId);使用Lamba表达式转换动态类型似乎是不可能的。如何解决这个问题,并能够在我的Lamba中使用我的对象o?谢谢附言:e.Item.DataItem属于CmsContent类型并且o.Conten

c# - 运算符 'op ' 不能应用于类型 'dynamic' 和 'lambda expression' 的操作数

我似乎无法将二元运算应用于lambda表达式、委托(delegate)和方法组。dynamicMyObject=newMyDynamicClass();MyObject>>=()=>1+1;第二行给出错误:Operator'>>='cannotbeappliedtooperandsoftype'dynamic'and'lambdaexpression'为什么?运算符功能不是由我的自定义TryBinaryOperation覆盖决定的吗? 最佳答案 这不是MyDynamicClass的问题,问题是您不能将lambda表达式作为动态表达式

c# - MSBuild 未处理的异常 : The FileName property should not be a directory unless UseShellExecute is set

版本dotnet核心SDK:2.1.403docker:18.09.7Linux内核:5.0.0-27Ubuntu:18.04.3问题我正在docker中运行一个ASP.NETCore项目。当我docker-composeup时,我得到以下信息:UnhandledException:Microsoft.Build.BackEnd.NodeFailedToLaunchException:TheFileNamepropertyshouldnotbeadirectoryunlessUseShellExecuteisset.--->System.ComponentModel.Win32Exce