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
Do not close this issue. This is a "meta issue". It is just for writing down any ideas and suggestions for KORM. Ideas here, once consulted, will be moved to separate issues.
Now, if we want to delete an entity, we can use direct SQL statement (ExecuteNonQuery), or DbSet. The disadvantage of ExecuteNonQuery is, that it does not have ane knowledge about entity type, so the SQL must be hand written. Disadvantage of DbSet is that we need to create an instance of the entity, just to have its ID. I'd like to have something which can be used without creating an entity instance:
_database.Delete<EntityType>(123)
We could support delete with condition (instead of just primary key):
Where to implement this (IDbSet, IDatabase...). And it should at least support int and long primary keys (generic of <TEntity, TKey>?), but better any keys (what about composite ones?).
What kind of expressions to support when deleting with condition and throw some exception if we cannot translate it into SQL.
Now we have some support for generated primary keys. But we only support int (no long). It is achieved by Key attribute. It would be better to have something like ValueGenerator attribute, which will generate value for column on INSERT. And it could be used for any column, not just primary key.
Timestamp column
This would be special column (for start marked with some attribute) of DateTime/DateTimeOffset type. Value for this column would be automatically set to current date and time on every INSERT or UPDATE.
Soft delete
It is common to use so-called soft delete instead of directly deleting a database record. The record is not deleted, it is only marked with IsDeleted flag.
It would be nice to support it directly in KORM.
I suggest something like this:
public class DatabaseConfiguration : DatabaseConfigurationBase
{
public override void OnModelCreating(ModelConfigurationBuilder modelBuilder)
{
modelBuilder.Entity<Document>()
.UseSoftDelete(entity => entity.IsDeleted);
}
}
After calling dbSet.CommitChanges(); KORM will call update IsDeleted = true.
We can have multiple classes to retrieve data from the same table. For example: DocumentHeader, DocumentVerySpecialDto, etc. It would be nice to define this filter for all these classes.
We need overload with string condition HasQueryFilter(string whereCondition, params object[] args);
Use ConnectionStrings section with named connection strings
We use our own setup of connection string in setting. We require ConnectionString section with ProviderName and ConnectionString subkeys. We could use default connection strings settings (as Entity Framework does it). The section name is ConnectionStrings and subkeys are name of connection strings. Provider can be integrated in connection string itself. When creating IDatabase, connection string name will be specified. If the name is not specified, default name DefaultConnection will be used.
Use different kind of configuration than attributes
Now some configuration is allowed only using attributes (Key, Alias). Something can be changed using custom ModelMapper. Maybe we can think about different kind of configuration instead of attributes.
Use new feature of C# 8.0 - Async Streams for async loading data
Use new C# 8.0 feature Async Streams for async obtaining data by KORM.
General info
Do not close this issue. This is a "meta issue". It is just for writing down any ideas and suggestions for KORM. Ideas here, once consulted, will be moved to separate issues.
SimplerDelete
of entitiesImplemented in #40.
Now, if we want to delete an entity, we can use direct SQL statement (
ExecuteNonQuery
), orDbSet
. The disadvantage ofExecuteNonQuery
is, that it does not have ane knowledge about entity type, so the SQL must be hand written. Disadvantage ofDbSet
is that we need to create an instance of the entity, just to have its ID. I'd like to have something which can be used without creating an entity instance:We could support delete with condition (instead of just primary key):
Things to think about:
IDbSet
,IDatabase
...). And it should at least supportint
andlong
primary keys (generic of<TEntity, TKey>
?), but better any keys (what about composite ones?).Value generators for columnsImplemented in #41.
Now we have some support for generated primary keys. But we only support
int
(nolong
). It is achieved byKey
attribute. It would be better to have something likeValueGenerator
attribute, which will generate value for column onINSERT
. And it could be used for any column, not just primary key.Timestamp column
This would be special column (for start marked with some attribute) of
DateTime
/DateTimeOffset
type. Value for this column would be automatically set to current date and time on everyINSERT
orUPDATE
.Soft delete
It is common to use so-called soft delete instead of directly deleting a database record. The record is not deleted, it is only marked with
IsDeleted
flag.It would be nice to support it directly in KORM.
I suggest something like this:
After calling
dbSet.CommitChanges();
KORM will call updateIsDeleted = true
.Global Query FiltersImplemented in #47
Discused in #42.
In many cases, we want to define a global filter to apply to each query. For example:
IsDeleted = false
,ParentId = 1
,UserId = ActiveUser.Id
, etc.It would be great to be able to define it in one place and KORM would automatically add this condition to every query.
KORM will automatically add a condition
((IsDeleted = 0) AND (ParentId = 1)
when calling any query usingQuery<Document>()
.Ignoring global filters
If I need to call a query without these conditions, I must explicitly say:
Things to think about
DocumentHeader
,DocumentVerySpecialDto
, etc. It would be nice to define this filter for all these classes.HasQueryFilter(string whereCondition, params object[] args);
UseConnectionStrings
section with named connection stringsImplemented in Kros.KORM.Extensions.Asp repository.
Filed in Kros.KORM.Extensions.Asp repository.
We use our own setup of connection string in setting. We require
ConnectionString
section withProviderName
andConnectionString
subkeys. We could use default connection strings settings (as Entity Framework does it). The section name isConnectionStrings
and subkeys are name of connection strings. Provider can be integrated in connection string itself. When creating IDatabase, connection string name will be specified. If the name is not specified, default nameDefaultConnection
will be used.Use different kind of configuration than attributesImplemented in #18
Now some configuration is allowed only using attributes (
Key
,Alias
). Something can be changed using customModelMapper
. Maybe we can think about different kind of configuration instead of attributes.Use new feature of C# 8.0 - Async Streams for async loading data
Use new C# 8.0 feature Async Streams for async obtaining data by KORM.
The text was updated successfully, but these errors were encountered: