내 VS LIGHTSWITCH 2013 포털 응용 프로그램에서 다른 내부 앱에 링크되는 타일을 만들 수 있습니다. 새 타일이 작성되면 이름이 'TileTitle + "User"'인 역할이 작성됩니다. 이렇게하면 사용자 역할에 따라 타일을 표시하거나 숨길 수 있습니다. 그러나 쿼리 필터 메서드에서 타일 엔터티를 필터링 할 때 IsInRole 메서드를 사용할 수 없다는 오류가 발생합니다. Expression Tree에서 오류가 발생했습니다
는 뒷조사 후 나는 식 트리를 사용해보기로 결정,이 내가 생각 해낸 것입니다 : 그러나 작동하지 않습니다partial void TileLinks_Filter(ref Expression<Func<TileLink, bool>> filter)
{
ParameterExpression p = Expression.Parameter(typeof(TileLink), "e");
MemberExpression ti = Expression.Property(p, "Title");
MethodInfo m2 = typeof(string).GetMethod("Concat", new[] { typeof(string), typeof(string) });
Type t = this.Application.User.GetType();
MethodInfo m = t.GetMethod("IsInRole");
Expression filterExpression = Expression.IsTrue(Expression.Call(Expression.Call(m2, ti, Expression.Constant(" User")), m));
filter = Expression.Lambda<Func<TileLink, bool>>(filterExpression, p);
// e => this.Application.User.IsInRole(e.Title + " User");
// this is what I would like to do
}
이, 나는이 아주 이상한 오류 메시지와 함께 왼쪽입니다.
Method 'Boolean IsInRole(System.String)' declared on type 'System.Security.Claims.ClaimsPrincipal' cannot be called with instance of type 'System.String'
동적으로 생성 된 역할을 기반으로 데이터를 필터링하는 데 도움주세요!