KlusterKite.Data
A bundle of generic actors and other abstractions to handle basic data work (mainly CRUD)
In every project, there is alway exists some data that is stored in the DB but is not under heavy load. But, nevertheless, there is need in some administration (or other) UI that handles this data.
BaseCrudActor<TContext>
There is a ready abstraction to handle basic CRUD operation with data. Just make a subclass of BaseCrudActor
and you can make operations with simple messages:
-
CrudActionMessage<TData, TId>
will perform CRUD operation with single data entityTData
with and id of typeTId
. Then it will send back theCrudActionResponse<TData>
message.In order to do this operations from the box the
DataFactory<TContext, TObject, TId>
should be implemented and registered with the DI. -
CollectionRequest<TObject>
to request the list of entities. The actor will reply with theCollectionResponse<TObject>
message.
Both messages can contain ApiRequest
subtree, that should be parsed on order to load related data.
KlusterKite.Data.EF
Very often EntityFramework.Core is used to work with DBMS. For this case there is a ready solution to work with data contexts and data factories.
EntityDataFactory<TContext, TObject, TId>
is ready to work with EF contexts and DbSets. It can parse the ApiRequest
to include the related data.
As for now, it is strongly recommended to use completely sync version of the factory (EntityDataFactorySync<TContext, TObject, TId>
) due to performance issues in EF. As soon as it will be fixed by MS, this recommendation will be removed.
To acquire context the UniversalContextFactory
is already registered in the DI by [KlusterKite.Data.EF
] plugin. All you need is to add the EF provider plugin and specify provider name and connection properties.
At this moment the are several DBMS drivers specified:
KlusterKite.Data.EF.Npgsql
to work with PostgresKlusterKite.Data.EF.InMemory
to work with mock database for test purposes