Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Check if requested property exists for Where and Order expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-ershov-fls committed Nov 27, 2018
1 parent 17d1360 commit 77827e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/QueryDesignerCore/Expressions/OrderExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public static IOrderedQueryable<T> GetOrderedQueryable<T>(this OrderFilter filte
private static PropertyInfo GetDeclaringProperty(Type t, string name)
{
var p = t.GetRuntimeProperty(name);

if (p == null)
{
throw new InvalidOperationException(string.Format("Property '{0}' not found on type '{1}'", name, t));
}

if (t != p.DeclaringType)
{
p = p.DeclaringType.GetRuntimeProperty(name);
Expand Down
6 changes: 6 additions & 0 deletions src/QueryDesignerCore/Expressions/WhereExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ private static PropertyInfo GetDeclaringProperty(Expression e, string name)
{
var t = e.Type;
var p = t.GetRuntimeProperty(name);

if (p == null)
{
throw new InvalidOperationException(string.Format("Property '{0}' not found on type '{1}'", name, t));
}

if (t != p.DeclaringType)
{
p = p.DeclaringType.GetRuntimeProperty(name);
Expand Down

0 comments on commit 77827e6

Please sign in to comment.