我有一个基本的ViewModel,其属性是一个复杂类型的List.绑定时,我似乎不知道要么获取值列表,要么根据发布的值(即视图排列)获取其他模型属性.
视图模型:
public class MyViewModel
{
public int Id { get; set; }
public string Property1 { get; set; }
public string Property2 { get; set; }
public List<MyDataItem> Data { get; set; }
}
public class MyDataItem
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器动作:
public ActionResult MyForm()
{
MyViewModel model = new MyViewModel();
model.Id = …Run Code Online (Sandbox Code Playgroud) 我正在使用ASP.Net MVC 3和Entity Framework代码优先构建的项目中使用mvc-mini-profiler.
一切都很有效,直到我尝试通过ProfiledDbConnection在文档中描述的方式包装连接来添加数据库分析.由于我使用的是DbContext,因此我尝试提供连接的方式是使用静态工厂方法构造函数:
public class MyDbContext : DbContext
{
public MyDbContext() : base(GetProfilerConnection(), true)
{ }
private static DbConnection GetProfilerConnection()
{
// Code below errors
//return ProfiledDbConnection.Get(new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionName"].ConnectionString));
// Code below works fine...
return new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionName"].ConnectionString);
}
//...
}
Run Code Online (Sandbox Code Playgroud)
使用时ProfiledDbConnection,我收到以下错误:
ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.
堆栈跟踪:
[ArgumentException: The connection is not of type 'System.Data.SqlClient.SqlConnection'.]
System.Data.SqlClient.SqlProviderUtilities.GetRequiredSqlConnection(DbConnection connection) +10486148
System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +77
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +44
[ProviderIncompatibleException: The provider did not …Run Code Online (Sandbox Code Playgroud) 我刚刚将Visual Studio扩展RazorGenerator升级到V1.5(上次更新时间为10/14/2012),现在出现以下问题.
如果我选择"运行自定义工具",现在编辑的每个cshtml文件都会删除生成的文件 The custom tool 'RazorGenerator' failed. The method or operation is not implemented.
我以前在我的项目中工作没有问题,但升级似乎打破了它.有谁知道如何解决这个问题?因为它是通过ExtensionManager安装的,所以我现在甚至无法回滚到以前的版本.
最新版本的Nuz中的RazorGenerator.MVC是1.4(2012年4月20日,星期五),所以版本不匹配可能是问题..?
我已经尝试重启VS和我的机器没有成功,我甚至卸载了扩展并重新安装,但也没有用.
Exception calling "RunCustomTool" with "0" argument(s): "The custom tool 'RazorGenerator' failed. The method or operation is not implemented."
At D:\Source\MySolution\MyProject\packages\RazorGenerator.Mvc.1.4.0.0\tools\RazorGenerator.psm1:32 char:32
+ $_.Object.RunCustomTool <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Exception calling "GetItem" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
At D:\Source\MySolution\MyProject\packages\RazorGenerator.Mvc.1.4.0.0\tools\RazorGenerator.psm1:62 char:46
+ $solutionExplorer.GetItem <<<< ("$SolutionName\$ProjectName$relativePath").UIHierarchyItems.Expanded …Run Code Online (Sandbox Code Playgroud) asp.net-mvc asp.net-mvc-3 visual-studio-extensions razorgenerator
我Microsoft.Web.RedisOutputCacheProvider按照https://msdn.microsoft.com/en-us/library/azure/dn798898.aspx中的说明安装了nuget软件包,用于在多个服务器实例上运行的Azure Web App ,并且收到以下错误:
When using a custom output cache provider like 'MyRedisOutputCache', only the following expiration policies and cache features are supported: file dependencies, absolute expirations, static validation callbacks and static substitution callbacks.
Run Code Online (Sandbox Code Playgroud)
配置设置如下:
<system.web>
<caching>
<outputCache defaultProvider="MyRedisOutputCache">
<providers>
<add name="MyRedisOutputCache"
type="Microsoft.Web.Redis.RedisOutputCacheProvider"
port="1234"
host="[my host]"
accessKey="[my access key]"
ssl="true" />
</providers>
</outputCache>
</caching>
</system.web>
Run Code Online (Sandbox Code Playgroud)
我已经尝试将其设置connectionString为有效的StackExchange.Redis连接字符串,而不是设置单个端口/主机等...但仍然收到相同的错误.
我们还Microsoft.Web.RedisSessionStateProvider使用相同的设置在同一个Web应用程序中运行,没有任何问题.
任何帮助,将不胜感激.