Geeksltd / Olive

Olive framework, for more productive cross platform .NET solutions. It's available under the GPL v3 license. See License.md for more information.
https://geeksltd.github.io/Olive
Other
44 stars 44 forks source link

Add nullable property type support for dynamodb. #337

Closed AmirHJabari closed 2 years ago

AmirHJabari commented 2 years ago

The DynamoDb provider wasn't able to predict Nullalbe<T> types. For example it was saving a DateTime? property like 17/03/2022 00:00:00, (default one) which calls

Value.ToStringOrEmpty()

not

 ((DateTime)Value).ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")

The ERROR:

System.InvalidOperationException: Unable to convert [17/03/2022 00:00:00] of type Amazon.DynamoDBv2.DocumentModel.Primitive to System.Nullable`1[[System.DateTime, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
   at Amazon.DynamoDBv2.Converter.FromEntry(DynamoDBEntry entry, Type targetType)
   at Amazon.DynamoDBv2.DynamoDBEntryConversion.ConvertFromEntry(Type outputType, DynamoDBEntry entry)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.FromDynamoDBEntry(SimplePropertyStorage propertyStorage, DynamoDBEntry entry, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.PopulateInstance(ItemStorage storage, Object instance, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.DocumentToObject(Type objectType, ItemStorage storage, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.DocumentToObject[T](ItemStorage storage, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.FromDocumentHelper[T](Document document, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.FromDocumentsHelper[T](IEnumerable`1 documents, DynamoDBFlatConfig flatConfig)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Amazon.DynamoDBv2.DataModel.AsyncSearch`1.GetRemainingAsync(CancellationToken cancellationToken)
   at Olive.Entities.Data.DynamoDBDataProvider`1.FindByConditions(IDatabaseQuery query)
   at Olive.Entities.Data.DynamoDBDataProvider`1.GetList(IDatabaseQuery query)
   at Olive.OliveExtensions.Get[TSource,TResult](Task`1 this, Func`2 expression)
   at Olive.Entities.Data.DatabaseQuery.LoadFromDatabase()
   at Olive.Entities.Data.DatabaseQuery.LoadFromDatabaseAndCache()
   at Olive.Entities.Data.DatabaseQuery.GetList()
   at Olive.Entities.Data.DatabaseQuery`1.GetList()
   at Controllers.SomethingController.GetSource(SomethingList info, Boolean all) in C:\Projects\**\Website\Controllers\Pages\SomethingController.cs:line 70
   *
m-sadegh-sh commented 2 years ago

@AmirHJabari A new version of the package has been released.