MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

AsQueryable for a class that has ExpandoObject

Hi All!

I have a class that looks like this:

public class Record
{

	[BsonElement("appName")]
	public string AppName
	{
		get { return this.appName; }
		set { this.appName = value; }
	}

	 
	[BsonElement("contents")]
	public ExpandoObject Contents { get; set; }

}

Now, all I want to do is to access the items inside Contents such as dateOfBirth to do something like this:

var collection =
database.GetCollection(“recordData”).AsQueryable()
.Where(x => (DateTime)x.Contents.First(z => z.Key == “dateOfBirth”).Value > DateTime.Now ).ToList();

But I am getting this exception:

System.NotSupportedException: ‘The expression tree is not supported: {document}{contents}’

Am I doing something wrong? Is there a way to run filters on ExpandoObjects using LINQ at all?