You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just trying out the time-series functionality and have come across some issues:
//[Collection("quote")]publicclassQuoteEntity:Entity{publicclassQuoteMetadata{//[Field("symbolpair")]publicstringSymbolPair{get;set;}}//[Field("metadata")]publicQuoteMetadataMetadata{get;set;}//[Field("timestamp")]publicDateTimeTimestamp{get;set;}//[Field("bid")]publicdecimalBid{get;set;}//[Field("ask")]publicdecimalAsk{get;set;}}publicclassQuoteRepository:RepositoryBase<QuoteEntity>{staticQuoteRepository(){try{// ISSUE #1: Calling DB.CreateCollectionAsync() when an existing collection already exists// will throw an exception, to get around this, need to implement a try{ } finally{}// ISSUE #2: When an entity class is marked with a [Collection] attribute, mongodb compass shows// the "QuoteEntity" collection name, but weird, it also shows "quote" collection.// Not sure if this has something to do with the [Collection] attribute messing with some parameters // --------// ISSUE #3: Using nameof(property) which is marked with a [Field] attribute causes exception when inserting//DB.CreateCollectionAsync<DatapointEntity>(o => {// o.TimeSeriesOptions = new(nameof(DatapointEntity.Timestamp),// nameof(DatapointEntity.MetaData),// TimeSeriesGranularity.Minutes);//}).Wait();// QUICKFIX for #3: Instead of using nameof(), must specify the literal name to make it work
DB.CreateCollectionAsync<DatapointEntity>(o =>{ o.TimeSeriesOptions =new("date","metadata", TimeSeriesGranularity.Minutes);}).Wait();// ISSUE #4: The collection is created BUT when you try to insert an entity marked with [Field] attributes// No insert occurs and multiple exceptions happen in VS2022}finally{}
DB.DatabaseFor<QuoteEntity>("DBNAME");
DB.Index<QuoteEntity>().Key(i => i.Metadata.SymbolPair, KeyType.Ascending).CreateAsync();
DB.Index<QuoteEntity>().Key(i => i.Timestamp, KeyType.Descending).Key(i => i.Metadata.SymbolPair, KeyType.Ascending).CreateAsync();}}
I am running this on VS2022 .NET6 (fully patched), MongoDB v5.0.9 (via Docker), MongoDB.Entities v20.26.5
The text was updated successfully, but these errors were encountered:
paolobriones
changed the title
Several Weird behavior when using TimeSeries
Several Weird behaviors when using TimeSeries
Jul 28, 2022
yes that's the expected and documented behavior. you can create timeseries collections just once using a migration.
i can't reproduce it. try below code in a fresh console app. works fine.
yes this is not possible because there's no way for TimeSeriesOptions can be made aware of custom field names. you can use reflection and grab the field names yourself and pass it in to the time series options.
I was just trying out the time-series functionality and have come across some issues:
I am running this on VS2022 .NET6 (fully patched), MongoDB v5.0.9 (via Docker), MongoDB.Entities v20.26.5
The text was updated successfully, but these errors were encountered: