Querying nested properties in mongo with c# and linq
<p>I'm trying to use linq queries to filter results from Mongo, but none of my queries using complex objects work:</p>

<p>The following works just fine :</p>

<pre><code>query.Where(o =&gt; (o.Name == "Joe"))
</code></pre>

<p>But this gives me errors:</p>

<pre><code>query.Where(o =&gt; (o.Address.HouseNumber == "1234"))
</code></pre>

<p>With version 2.1.1 of the c# drivers if I use the legacy drivers I get:</p>

<blockquote>
  <p>Unable to determine the serialization information for the expression:
  p.Address.HouseNumber</p>
  
  <p>at
  MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.GetSerializationInfo(Expression
  node, Dictionary<code>2 serializationInfoCache)    at
  MongoDB.Driver.Linq.Utils.BsonSerializationInfoHelper.GetSerializationInfo(Expression
  node)    at
  MongoDB.Driver.Linq.PredicateTranslator.BuildComparisonQuery(Expression
  variableExpression, ExpressionType operatorType, ConstantExpression
  constantExpression)    at
  MongoDB.Driver.Linq.PredicateTranslator.BuildComparisonQuery(BinaryExpression
  binaryExpression)    at
  MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression
  expression)    at
  MongoDB.Driver.Linq.PredicateTranslator.BuildAndAlsoQuery(BinaryExpression
  binaryExpression)    at
  MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression
  expression)    at MongoDB.Driver.Linq.SelectQuery.BuildQuery()    at
  MongoDB.Driver.Linq.SelectQuery.Execute()    at
  MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) 
  at MongoDB.Driver.Linq.MongoQueryable</code>1.GetEnumerator()    at
  System.Collections.Generic.List<code>1..ctor(IEnumerable</code>1 collection)<br>
  at System.Linq.Enumerable.ToList[TSource](IEnumerable<code>1 source)    at
  Core.Persistence.LegacyMongoDb.LegacyMongoDbImp.&lt;QueryAsync&gt;d__10</code>1.MoveNext()
  in
  C:\Users...\src\Core.Persistence.LegacyMongoDb\LegacyMongoDb.Implementation.cs:line
  84</p>
</blockquote>

<p>If I use the current version of the drivers I get:</p>

<blockquote>
  <p>[Address].HouseNumber is not supported.</p>
  
  <p>at
  MongoDB.Driver.Linq.Translators.PredicateTranslator.GetFieldExpression(Expression
  expression)    at
  MongoDB.Driver.Linq.Translators.PredicateTranslator.TranslateComparison(Expression
  variableExpression, ExpressionType operatorType, ConstantExpression
  constantExpression)    at
  MongoDB.Driver.Linq.Translators.PredicateTranslator.TranslateComparison(BinaryExpression
  binaryExpression)    at
  MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression
  node)    at
  MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression
  node, IBsonSerializerRegistry serializerRegistry)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateWhere(WhereExpression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateSkip(SkipExpression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateTake(TakeExpression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression
  node)    at
  MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression
  node, IBsonSerializerRegistry serializerRegistry)    at
  MongoDB.Driver.Linq.MongoQueryProviderImpl<code>1.Translate(Expression
  expression)    at
  MongoDB.Driver.Linq.MongoQueryProviderImpl</code>1.ExecuteAsync[TResult](Expression
  expression, CancellationToken cancellationToken)    at
  MongoDB.Driver.Linq.MongoQueryableImpl<code>2.ToCursorAsync(CancellationToken
  cancellationToken)    at
  MongoDB.Driver.IAsyncCursorSourceExtensions.&lt;ToListAsync&gt;d__4</code>1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---    at
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
  task)    at
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task)    at System.Runtime.CompilerServices.TaskAwaiter<code>1.GetResult() 
  at Core.Persistence.MongoDb.MongoDbImp.&lt;QueryAsync&gt;d__12</code>1.MoveNext()
  in
  C:\Users...\libs\mojio.core\src\Core.Persistence.MongoDb\MongoDb.Implementation.cs:line
  68</p>
</blockquote>

<p>I'm super stuck any help in the right direction would be appreciated</p>

<p>EDIT:</p>

<pre><code>public class User : Base&lt;User&gt;, IUser
{
     public string Name { get; set; }
     public IAddress Address { get; set; }
}


public class Address : IAddress
{
     public string HouseNumber { get; set; }
     public string City { get; set; }
     public string Country { get; set; }

}
</code></pre>