ormkephas

Is Kephas.Data some kind of ORM?


Digging more through the Kephas Framework I noticed that Kephas.Data provides a functionality similar to that of classical ORMs. However, I did not find any kind of documentation about how to connect to databases or, at least, to clarify whether my assumption is correct or not.


Solution

  • No, Kephas.Data is an abstraction over data persistence. It can be mapped over typical ORMs, or it can be bound directly to a persistance store, like MongoDB. Here are some starting points:

        public class DataConsumer
        {
            IExportFactory<IDataSpace> dataSpaceFactory;
    
            public DataConsumer(IExportFactory<IDataSpace> dataSpaceFactory)
            {
                this.dataSpaceFactory = dataSpaceFactory;
            }
    
            public async Task<> GetDocumentsCountAsync(CancellationToken token)
            {
                using (var dataSpace = dataSpaceFactory.CreateExportedValue())
                {
                    var documentCount = await dataSpace.Query<Document>().CountAsync().PreserveThreadContext();
                    return documentCount;
                } 
            }
        }
    

    A DataSpace can hold multiple DataContexts, each DataContext being responsible for a dedicated data store. The discrimination is done by entity type.

    Each DataContext implementation is bound to the specific store. By default, Kephas provides the MongoDB adapter, an Entity Framework adapter being also planned.

    A special feature is the integration of DataBehaviors, which are invoked upon data or query operations.

    For more information please consult https://github.com/kephas-software/kephas/wiki/Architecture-of-data-access and the similar wiki pages.