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
{{ message }}
This repository has been archived by the owner on May 23, 2024. It is now read-only.
In ApplicationCore/Entities/BaseEntity.cs you define that the ID-property of an entity is always of type int and always named "Id". I've got a lot of older apps where the ID-property (PK-column in DB) is of different type like string or GUID and has a different name (often Entity+"_ID", but also some complete other naming schemes).
You use the same assumption about the type of ID-property onwards in the interfaces IRepository and IImageService (you assume that the ID of an image is of type int).
Infrastructure/Data/EfRepository then implements this interface and so also here int is backed in.
Is it possible for you to make BaseEntity having a "generic" type for the ID-property and also build in a way of having a different name for the ID-property on a per-entity-base?
Regards
Dietmar
The text was updated successfully, but these errors were encountered:
I think this repo is just for demostration, you can write your generic version of EntityBase.
About the name of key field, it can be mapped using ColumnAttribute, so that's not an issue.
Mine looks like this:
public class BaseEntity<T>
{
[Column("id")]
[Key]
public T Id { get; set; }
[Column("ctime")]
public DateTime CTime { get; set; } = DateTime.Now;
[Column("utime")]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime UTime { get; set; }
[Column("del")]
public DeleteState Del { get; set; } = DeleteState.NotDeleted;
}
In ApplicationCore/Entities/BaseEntity.cs you define that the ID-property of an entity is always of type
int
and always named "Id". I've got a lot of older apps where the ID-property (PK-column in DB) is of different type like string or GUID and has a different name (often Entity+"_ID", but also some complete other naming schemes).You use the same assumption about the type of ID-property onwards in the interfaces IRepository and IImageService (you assume that the ID of an image is of type
int
).Infrastructure/Data/EfRepository then implements this interface and so also here int is backed in.
Is it possible for you to make BaseEntity having a "generic" type for the ID-property and also build in a way of having a different name for the ID-property on a per-entity-base?
Regards
Dietmar
The text was updated successfully, but these errors were encountered: