In my Mongo db collection have 2 date fields TimeStamp, OpEndTime, I need to take order by OpEndTime-TimeStamp. It is working with a small amount of data. For huge data throw exception out of ram space. So need to create the index with difference of OpEndTime and TimeStamp. I don't know how to create it. I am using C# mongo db driver
I tried like below DBContext.ClientDb.Repository(collection).Indexes.CreateOne(Builders.IndexKeys.Ascending(i =>i.OpEndTime- i.TimeStamp));
but am getting error like below
An exception of type 'System.InvalidOperationException' occurred in MongoDB.Driver.dll but was not handled in user code Additional information: Unable to determine the serialization information for i => Convert((i.OpEndTime - i.TimeStamp)).