Repodb: Class, Property Mapper concurrent dictionary problem

Created on 29 May 2020  路  4Comments  路  Source: mikependon/RepoDB

I tested the property mapper. When it is first run it cannot find property in the map.

PropertyMapper.Add<ShelfCell>(x => x.RowIndex, "row_index");
PropertyMappedNameCache.Get<ShelfCell>(x => x.RowIndex)

First time calling, return the "RowIndex". Second time call, it fixing and returning "row_index". I only catch error with try/catch.

I think concurrent dictionary working on background and it is not complete until first time call.

I am working on AvaloniaUI. Maybe thread problem. I think Concurrent Dictionary convert to normal Dictionary.

Goodday

question

All 4 comments

Do you use the latest version? There were issues on the first few beta releases of the Implicit Mappings. If yes...

First time calling, return the "RowIndex". Second time call, it fixing and returning "row_index". I only catch error with try/catch.

Do you only use this PropertyMappedNameCache.Get<ShelfCell>(x => x.RowIndex) to get the mappings?

I hope you did not call these methods.

  • PropertyMapper.Clear()
  • PropertyMappedNameCache.Flush()

Yes, i am using 1.0.11.

if (!MySqlBootstrap.IsInitialized) {
    MySqlBootstrap.Initialize();
}
ClassMapper.Add<ShelfCell>("shelf_cell");
PropertyMapper.Add<ShelfCell>(x => x.Id, "id");
PropertyMapper.Add<ShelfCell>(x => x.ShelfId, "shelf_id");
PropertyMapper.Add<ShelfCell>(x => x.Barcode, "barcode");
PropertyMapper.Add<ShelfCell>(x => x.RowIndex, "row_index");
PropertyMapper.Add<ShelfCell>(x => x.ColumnIndex, "column_index");
PropertyMapper.Add<ShelfCell>(x => x.Status, "status");
QueryField queryField = new QueryField(PropertyMappedNameCache.Get<ShelfCell>(x => x.RowIndex), Operation.Equal, RowIndex);

Sometimes throw error in AvaloniaApp sometimes nothing. I think the problem is about timing.

Console output

I can't replicate your case. Can you try do the code below and see what's the value of the where variable?

var dbSetting = DbSettingMapper.Get<MySqlConnection>();
var queryField = new QueryField(PropertyMappedNameCache.Get<ShelfCell>(x => x.RowIndex), Operation.Equal, 1);
var queryGroup = new QueryGroup(queryField);
var where = queryGroup.GetString(dbSetting); // (`row_index` = @row_index)

Okey, i solved that problem. I am using my db code in external library. I call the library before Avalonia App.

Was this page helpful?
0 / 5 - 0 ratings