This project has moved. For the latest updates, please go here.

Generic ID type?

Jul 23, 2012 at 10:37 AM

I already have some code and domain model based on IEntity

public interface IEntity
    {
        long Id { get; set; }
    }

This makes me hard to integrate MongoRepository to my solution. Does it make sense to use some generic IEntity in MongoRepository, something like

 public interface IEntity<T>
    {
        T Id { get; set; }
    }
?

For now I have choice:

  • rebuilding my domain and loose supporting other repository implementations
  • recompile MongoRepository from sources

I don't like the both.

 

Coordinator
Jul 24, 2012 at 2:11 PM

Somehow you'd need to identify the Id property as "the ID" and currently this is done by adding the [BsonId] attribute in the IEntity.

If you have any suggestion as how we could solve this (without requiring the [BsonId] attribute, which would "leak" mongocsharpdriver-specific implementation details) then please lets hear them.