diff --git a/src/Infrastructure/Repository/Mongo/IIdentifiable.cs b/src/Infrastructure/Repository/Mongo/IIdentifiable.cs index ab75d10..6ccc225 100644 --- a/src/Infrastructure/Repository/Mongo/IIdentifiable.cs +++ b/src/Infrastructure/Repository/Mongo/IIdentifiable.cs @@ -1,6 +1,9 @@ -namespace Infrastructure.Repository.Mongo; +using MongoDB.Bson.Serialization.Attributes; -public interface IIdentifiable +namespace Infrastructure.Repository.Mongo; + +public interface IIdentifiable where TKey : IEquatable { - string Id { get; set; } + [BsonId] + TKey Id { get; set; } } \ No newline at end of file diff --git a/src/Infrastructure/Repository/Mongo/IMongoRepositoryBase.cs b/src/Infrastructure/Repository/Mongo/IMongoRepositoryBase.cs index c5b9396..3f81e56 100644 --- a/src/Infrastructure/Repository/Mongo/IMongoRepositoryBase.cs +++ b/src/Infrastructure/Repository/Mongo/IMongoRepositoryBase.cs @@ -3,7 +3,7 @@ namespace Infrastructure.Repository.Mongo; public interface IMongoRepositoryBase - where TEntity : class, IIdentifiable, new() where TKey : IEquatable + where TEntity : class, IIdentifiable, new() where TKey : IEquatable { IMongoCollection Collection { get; } diff --git a/src/Infrastructure/Repository/Mongo/MongoRepositoryBase.cs b/src/Infrastructure/Repository/Mongo/MongoRepositoryBase.cs index 875165e..4da6186 100644 --- a/src/Infrastructure/Repository/Mongo/MongoRepositoryBase.cs +++ b/src/Infrastructure/Repository/Mongo/MongoRepositoryBase.cs @@ -6,7 +6,7 @@ namespace Infrastructure.Repository.Mongo; public abstract class MongoRepositoryBase(IMongoDatabase database) : IMongoRepositoryBase - where TEntity : class, IIdentifiable, new() + where TEntity : class, IIdentifiable, new() where TKey : IEquatable { private readonly IMongoCollection _collection = database.GetCollection(typeof(TEntity).Name);