草庐IT

eval_model_params

全部标签

c# - 使用具有 "params"参数的反射调用函数 (MethodBase)

我有两个函数的MethodBases:publicstaticintAdd(paramsint[]parameters){/*...*/}publicstaticintAdd(inta,intb){/*...*/}我有一个通过我创建的类调用MethodBases的函数:MethodBaseMethod;objectTarget;publicobjectcall(paramsobject[]input){returnMethod.Invoke(Target,input);}现在如果我AddTwoMethod.call(5,4);它工作正常。如果我使用AddMethod.call(5,4)

c# - MVC 错误 : The model item passed into the dictionary is null

我只是想建立一个View,但我收到以下错误:System.InvalidOperationException:Themodelitempassedintothedictionaryisnull,butthisdictionaryrequiresanon-nullmodelitemoftype'System.DateTime现在,我知道为什么会出现这种情况,数据库中的特定字段是空值,但它应该是空值,因为这是稍后编辑的内容。这是我的代码:ActionpublicActionResultView(Int64?Id){ModelContainerctn=newModelContainer();

c# - 当部分 View 位于共享文件夹中时,ASP.NET MVC '@model dynamic' 无法识别模型属性

不重复:MVCRazordynamicmodel,'object'doesnotcontaindefinitionfor'PropertyName'根据那里的答案,AccordingtoDavidEbbo,youcan'tpassananonymoustypeintoadynamically-typedviewbecausetheanonymoustypesarecompiledasinternal.SincetheCSHTMLviewiscompiledintoaseparateassembly,itcan'taccesstheanonymoustype'sproperties.为什

c# - 扩展 ASP.NET 身份角色 : IdentityRole is not part of the model for the current context

我正在尝试在我的MVC5应用程序中使用新的ASP.NETIdentity,特别是我正在尝试将ASP.NETIdentity集成到现有数据库中。我已经阅读了有关DBFirst和ASP.NETIdentity的SO问题/答案,并且遵循了所有建议我仍然无法向我的数据库添加角色,尽管我在添加用户时没有问题。这是我的代码:varcontext=newPayrollDBEntities();varroleManager=newRoleManager(newRoleStore(context));boolroleExists=roleManager.RoleExists(roleDto.Name);

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - OData 和 WebAPI : Navigation property not present on model

我正在尝试使用EntityFramework、WebAPI、OData和Angular客户端组合一个简单的玩具项目。一切正常,除了我在其中一个模型上放置的导航属性似乎不起作用。当我使用$expand调用我的API时,返回的实体没有它们的导航属性。我的类是Dog和Owner,看起来像这样:publicclassDog{//Properties[Key]publicGuidId{get;set;}publicStringName{get;set;}[Required]publicDogBreedBreed{get;set;}publicintAge{get;set;}publicintWe

c# - 可选参数后跟 Params

这个问题在这里已经有了答案:C#4.0,optionalparametersandparamsdonotworktogether(3个答案)关闭9年前。所以我看到可以有一个方法签名,其中第一个参数提供默认值,第二个参数是参数集合。我看不到的是实际使用第一个参数的默认值的方法。有可能吗?示例方法:voidWaitAllTask​​s(stringmessage="RunningTask.WaitAll",paramsTask[]tasks);我最初尝试在调用方法时省略消息参数,还尝试使用命名参数,这不适用于params。可以编译,但可以使用吗?

c# - 有趣的 "params of ref"功能,有什么解决方法吗?

我想知道对于值类型是否有任何类似的方法......publicstaticclassExtensionMethods{publicstaticvoidSetTo(thisBooleansource,paramsBoolean[]bools){for(inti=0;i那么这将是可能的:Booleana=true,b,c=true,d=true,e;b.SetTo(a,c,d,e);当然,这是行不通的,因为bool是值类型,所以它们作为值而不是引用传递给函数。除了将值类型包装成引用类型(通过创建另一个类)之外,还有什么方法可以在使用params修饰符时通过引用(ref)将变量传递给函数?

c# - “模型”与声明“System.Web.Mvc.WebViewPage<TModel>.Model”冲突

我想显示以下客户对象。publicClassCustomer{publiclongId{get;set;}publicstringName{get;set;}publicAddressAddressInfo{get;set;}}publicclassAddress{publicstringDetails{get;set;}publicCityCityInfo{get;set;}publicRegionRegionInfo{get;set;}}并且有一个Controller返回给客户查看publicActionResultGetCustomer(longId){returnView("C

c# - 将 Eval ("bitValue") 转换为 Bool

我在ItemTemplate中有一个带有超链接控件的ListView。如果返回值为0(假),我想显示链接,如果返回值为1(真),则不显示链接。到目前为止我有这个:'Text="ReviewEnquiry"Visible=''/>...但这会导致“指定的转换无效”异常。我在其他地方看到的示例表明这应该有效。我可以确认Locked列只返回0或1(来自SQLServer)——当然这些应该很容易从bit/int转换为bool?? 最佳答案 如果Locked是一个int你应该这样做:但是这也应该有效,所以当Locked>0时它返回true无论