我有一个域实体,它有一个标记的枚举作为属性.标记的枚举是这些实体的目标受众.然后,用户具有他们应该看到的实体的标记枚举值.我试图找出正确的表达式来选择满足用户目标受众的实体.
public class File
{
public virtual TargetAudience TargetAudience { get; set; }
}
[Flags]
public enum TargetAudience
{
Audience1 = 1,
Audience2 = 2,
Audience3 = 4,
Audience4 = 8
}
Run Code Online (Sandbox Code Playgroud)
表达式:(这在a上执行时有效IList<File>,但对数据库的查询不起作用.)
public Expression<Func<File, bool>> Expression
{
get { return ((x.TargetAudience & UserTargetedAudience) > 0); }
}
Run Code Online (Sandbox Code Playgroud)
任何的意见都将会有帮助.
我遇到了一个asp.net表单身份验证的奇怪问题.此问题仅发生在已成功登录的30多个用户中的3个用户.我使用的是非常基本的身份验证代码,我已多次使用并且从未见过这个问题.用户成功进行身份验证并创建auth cookie后,将调用cookie,并调用response.redirect到FormsAuthentication.GetRedirect(userid,false).命中Global.asax中的Application_AuthenticateRequest方法.
// Extract the forms authentication cookie
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie)
{
// There is no authentication cookie.
return;
}
Run Code Online (Sandbox Code Playgroud)
因此,在保存"好"cookie之后立即发生重定向,cookie就为空.我已通过调试器运行代码,并且cookie在这3个用户上仅为null.但是cookie看起来与成功登录的许多用户的cookie相同.
有任何想法吗?这是应该正常工作的标准代码.
有没有办法知道在调用之前调用TextReader.Read或TextReader.ReadToEnd调用会挂起而不抛出exeption?
try
{
using (var filterReader = new EPocalipse.IFilter.FilterReader(tempFileName))
{
mediaContent = filterReader.ReadToEnd();
}
}
catch (Exception e)
{
Log.Error("DealerPortalIndex Error on file: " + tempFileName, e, this);
mediaContent = string.Empty;
}
Run Code Online (Sandbox Code Playgroud)
filterReader.ReadToEnd()挂起并且永远不会在某个.xls文件上抛出异常(可能更多文件)
我也尝试使用filterReader.Read(char {},int,int)来读取块并获得相同的问题.