-
-
Notifications
You must be signed in to change notification settings - Fork 240
Closed
Labels
Description
[Theory]
[InlineData("Prop", "TestProp")]
[InlineData("Field", "TestField")]
public void Parse_StaticPropertyOrField_In_NonStaticClass1(string name, string value)
{
// Arrange
var ints = new int[1].AsQueryable();
// Act
var result = ints.Select<string>($"new {typeof(NonStaticClassExample)}().{name}").First();
// Assert
Assert.Equal(value, result);
}
[Theory]
[InlineData("Prop", "TestProp")]
[InlineData("Field", "TestField")]
public void Parse_StaticPropertyOrField_In_NonStaticClass2(string name, string value)
{
// Arrange
var ints = new NonStaticClassExample[] { new NonStaticClassExample() }.AsQueryable();
// Act
var result = ints.Select<string>(name).First();
// Assert
Assert.Equal(value, result);
}
}
[DynamicLinqType]
public class NonStaticClassExample
{
public static string Prop { get; set; } = "TestProp";
public static string Field = "TestField";
}Both tests throw:
System.Linq.Dynamic.Core.Exceptions.ParseException : No property or field 'Field' exists in type 'NonStaticClassExample'
System.Linq.Dynamic.Core.Exceptions.ParseException : No property or field 'Prop' exists in type 'NonStaticClassExample'