我已经使用ASP.net会员多年,我刚刚开始尝试ASP.net身份.他们刚刚发布了2.0版,它应该支持int主键.我已经定义了我的自定义标识类,以获得整数主键支持:
public class User : IdentityUser<int, UserLogin, UserRole, UserClaim>
{
}
public class UserLogin : IdentityUserLogin<int>
{
}
public class Role : IdentityRole<int, UserRole>
{
public string Description { get; set; } // Custom description field on roles
}
public class UserRole : IdentityUserRole<int>
{
}
public class UserClaim : IdentityUserClaim<int>
{
}
public class MyDbContext : IdentityDbContext<User, Role, int, UserLogin, UserRole, UserClaim>
{
public MyDbContext() : this("MyDB") { }
public MyDbContext(string connStringName) : base(connStringName)
{
this.Configuration.LazyLoadingEnabled = …Run Code Online (Sandbox Code Playgroud) 只是好奇Skip&Take应该如何工作.我得到了我想在客户端看到的结果,但是当我连接AnjLab SQL Profiler并查看正在执行的SQL时,它看起来好像在查询并将整个行集返回到客户.
是否真的返回所有行,然后在客户端使用LINQ对事物进行排序和缩小?
我尝试过使用Entity Framework和Linq to SQL; 两者似乎都有相同的行为.
不确定它有什么不同,但我在VWD 2010中使用C#.
任何见解?
public IEnumerable<Store> ListStores(Func<Store, string> sort, bool desc, int page, int pageSize, out int totalRecords)
{
var context = new TectonicEntities();
totalRecords = context.Stores.Count();
int skipRows = (page - 1) * pageSize;
if (desc)
return context.Stores.OrderByDescending(sort).Skip(skipRows).Take(pageSize).ToList();
return context.Stores.OrderBy(sort).Skip(skipRows).Take(pageSize).ToList();
}
Run Code Online (Sandbox Code Playgroud)
结果SQL(注意:我排除了Count查询):
SELECT
[Extent1].[ID] AS [ID],
[Extent1].[Name] AS [Name],
[Extent1].[LegalName] AS [LegalName],
[Extent1].[YearEstablished] AS [YearEstablished],
[Extent1].[DiskPath] AS [DiskPath],
[Extent1].[URL] AS [URL],
[Extent1].[SecureURL] AS [SecureURL],
[Extent1].[UseSSL] AS [UseSSL]
FROM [dbo].[tec_Stores] AS [Extent1] …Run Code Online (Sandbox Code Playgroud) 我开始开发一个新的MVC应用程序,其中实体框架代码优先,Unity用于依赖注入.我使用EF5和Unity,因为我认为他们应该在Medium Trust中工作.但是,当我把<trust level="Medium" />标记扔进我的时候web.config,我开始获得反射权限异常.
似乎每当我超越使用像System.Data.SqlClientADO.net 这样的内置东西时,我总是会遇到Medium Trust中的问题.自动映射器:失败.NHibernate:失败.MySQL:失败.EF5代码优先:失败.国际奥委会:失败.
我只是在追逐梦想吗?是否有可能使用将在Medium Trust中运行的现代技术来实现构建良好且可测试的Web应用程序?
在虚拟机/虚拟服务器/云计算时代(甚至一些将您的应用程序池设置为完全信任的共享主机),是否有人发现为中型信任开发值得付出努力?
我有以下布局模板:
<div id="columns" class="@View.LayoutClass">
<div id="mainColWrap">
<div id="mainCol">
@RenderBody()
</div>
</div>
@if (View.ShowLeftCol){
<div id="leftCol">
@RenderSection("LeftCol", required: false)
</div>
}
@if (View.ShowRightCol){
<div id="rightCol">
@RenderSection("RightCol", required: false)
</div>
}
</div>
Run Code Online (Sandbox Code Playgroud)
如果View.ShowLeftCol或View.ShowRightCol设置为false,则会出现以下错误:
已定义以下部分,但尚未针对布局页面"〜/ Views/Shared/_Layout.cshtml":"RightCol"进行渲染.
我正在尝试使用单个布局模板,而不是尝试在运行时动态选择模板.有没有办法忽略这个错误并继续渲染?任何人都可以想到另一种实现方式,这将允许我用Razor动态显示/隐藏列?
谢谢!
有没有办法禁用某个验证器(信用卡)的jQuery验证,以便它只发生在onblur而不是onkeyup?
基于jQuery Validator文档,我想我可以做这样的事情:
$(function () {
$("[data-val-creditcard]").validate({
onkeyup: false
})
});
Run Code Online (Sandbox Code Playgroud)
但是,它似乎没有起作用.
我还尝试在我的验证器上执行以下操作:
public class CreditCardValidator : DataAnnotationsModelValidator<CreditCardAttribute>
{
string _message;
public CreditCardValidator(ModelMetadata metadata, ControllerContext context, CreditCardAttribute attribute)
: base(metadata, context, attribute)
{
_message = attribute.ErrorMessage;
}
public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()
{
var rule = new ModelClientValidationRule
{
ErrorMessage = _message,
ValidationType = "creditcard"
};
rule.ValidationParameters.Add("onkeyup", false);
return new[] { rule };
}
}
Run Code Online (Sandbox Code Playgroud)
它也不起作用,但我只是在正确使用ValidationParameters.
在表单中输入信用卡号并将其随机从无效更改为有效,然后返回无效,这有点烦人.
有任何想法吗?谢谢!
它看起来像在Entity Framework 6.1中,它们添加了通过新HasColumnAnnotation方法创建表索引的功能.我创建了一些辅助扩展来加速这个过程:
public static class MappingExtensions
{
public static StringPropertyConfiguration HasIndex(this StringPropertyConfiguration config, bool isUnique = false)
{
return config.HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = isUnique }));
}
public static StringPropertyConfiguration HasIndex(this StringPropertyConfiguration config, string name, int order = 1, bool isUnique = false)
{
return config.HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute(name, order) { IsUnique = isUnique }));
}
public static PrimitivePropertyConfiguration HasIndex(this PrimitivePropertyConfiguration config, bool isUnique = false)
{
return config.HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = …Run Code Online (Sandbox Code Playgroud) #tooltip
{
position: absolute;
width:auto;
min-width:50px;
max-width:250px;
padding:10px;
background-color:#eee;
border:1px solid #aaa;
}
Run Code Online (Sandbox Code Playgroud)
基于这种风格,我希望我的工具提示缩小或增长以适应内容,低至50px或高达250px.但是,当内容换行到下一行时,max-width属性似乎超出了我的width属性.当句子末尾的单词很长时,它看起来像留下了一堆填充(见截图),这是一种美学的东西.这是正常的行为吗?

是否有理由不使用dynamic-insert/ dynamic-update用于NHibernate?我问的唯一原因是它似乎是我想要启用的默认设置,而不是我必须配置的东西.
使用这些动态属性时是否有任何问题需要注意?
昨晚我正在使用FormsAuthentication开发一个新项目,并且正在自定义票证以包含安全令牌,因此如果用户在一个浏览器中注销,它将在所有这些注册表中注销.在查看ASP.net Identity的最新版本时,看起来它已经内置了这个功能.
我创建了一个新的测试MVC 5 Web应用程序,启用了个人帐户.注册和身份验证开箱即用.
然而,我注意到,失败的登录尝试不递增AccessFailedCount领域AspNetUsers表.由于这不会增加,我可以尝试尽可能多的失败登录尝试,而不会让帐户被锁定.
如何在ASP.net Identity 2.0上启用AccessFailedCount和Lockout功能?
是否应该asp-在Razor/MVC 6中为新标签助手提供Intellisense ?我正在关注Shawn Wildermuth的一个关于Pluralsight的课程并且一切正常,但我认为当我开始asp-在标签上作为属性打字时我应该得到智能感知.
如果它应该在那里你有什么可能导致它消失的想法?
我正在使用Visual Studio 2015社区,以及针对Kestrel,Mvc和TagHelpers的.Net依赖项的RC1-Final版本.
c# ×5
asp.net ×4
asp.net-mvc ×4
razor ×2
.net ×1
css ×1
jquery ×1
linq-to-sql ×1
medium-trust ×1
nhibernate ×1
tag-helpers ×1