Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to handle Array #64

Open
KarthikKarunanithy opened this issue Mar 13, 2020 · 3 comments
Open

Unable to handle Array #64

KarthikKarunanithy opened this issue Mar 13, 2020 · 3 comments

Comments

@KarthikKarunanithy
Copy link

Hi, I have just started to look into your library and it look and the test cases are helpful. I have a class object with array eg: Contact[] Contacts. Your library only supports IList and in GetExpression it throws an out of bounds exception in ProcessListStatement at
var type param.Type.GetProperty(basePropertyName).PropertyType.GetGenericArguments()[0];

Can you please let me know if there is a different way to handle this?

@justinushermawan
Copy link

Hi, have you found the solution for this?

I have the same issue.

@KarthikKarunanithy
Copy link
Author

KarthikKarunanithy commented Nov 11, 2020 via email

@justinushermawan
Copy link

Hi, thank you. I just tried it but with no luck.

I modified some in the ProcessListStatement() method:

...
var propType = param.Type.GetProperty(basePropertyName).PropertyType;
var type = propType.IsArray ? propType.GetElementType() : propType.GetGenericArguments()[0];
...

My test case:

var indexes = new Dictionary<long, Index>();
indexes.Add(1, new Index { Position = 1000, Values = new object[3] { "Welly", "Chandra", 26 } });
indexes.Add(2, new Index { Position = 1001, Values = new object[3] { "Darma", "Angelo", 25 } });
indexes.Add(3, new Index { Position = 1002, Values = new object[3] { "Abby", "Yeremia", 28 } });
indexes.Add(4, new Index { Position = 1003, Values = new object[3] { "Yonathan", "Gunawan", 22 } });
indexes.Add(5, new Index { Position = 1004, Values = new object[3] { "Aldy", "Santoso", 24 } });
var filter = new Filter<Index>();
filter.By("Values[1]", Operation.EqualTo, "Chandra", Connector.Or);
filter.By("Values[2]", Operation.EqualTo, 28);

public class Index
{
   public long Position { get; set; }

   public object[] Values { get; set; }
}

Error message:
System.ArgumentException: '1' is not a member of type 'System.Object' (Parameter 'propertyOrFieldName')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants