Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1468

Unable to determine the serialization information for c => Convert(c).Id

      Since we went from version 2.0.1 to 2.1.0 we get this error: Unable to determine the serialization information for c => Convert(c).Id

      Here's the exception:

      System.AggregateException : One or more errors occurred.
        ----> System.InvalidOperationException : Unable to determine the serialization information for c => Convert(c).Id.
         at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
         at RC.RcGraph.Infrastructure.SmokeTests.NewsStories.NewsStoryRepositoryTests.GetByIds() in NewsStoryRepositoryTests.cs: line 137
      --InvalidOperationException
         at MongoDB.Driver.ExpressionFieldDefinition`2.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
         at MongoDB.Driver.SingleItemAsArrayOperatorFilterDefinition`2.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
         at MongoDB.Driver.MongoCollectionImpl`1.FindAsync(FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
         at MongoDB.Driver.IAsyncCursorSourceExtensions.<ToListAsync>d__4`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`1.GetResult()
         at RC.RcGraph.Infrastructure.Util.MongoBaseContentRepository`1.<GetByIdsAsync>d__c.MoveNext() in MongoBaseContentRepository.cs: line 68
      

      Here's the object structure:

      public interface IContent {
        int Id { get; }
      }
      
      public class News : IContent {
        public int Id { get; private set; }
      }
      
      public abstract BaseRepository<T> where T : IContent {
        public async Task<List<T>> GetByIdsAsync(IEnumerable<int> ids) {
          var filter = Builders<T>.Filter.In(c => c.Id, ids);
          return await GetCollection()
                            .Find(filter)
                            .ToListAsync();
        }
      }
      

      Here are the conventions:

      BsonClassMap.RegisterClassMap<News>(cm => { cm.AutoMap() });
      

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            frederik.charest@gmail.com Frédérik Charest
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: