LiteDB icon indicating copy to clipboard operation
LiteDB copied to clipboard

[Question] : Better approach for creating index when using repository pattern?

Open jeshwel opened this issue 5 years ago • 4 comments

Hi,

I am performing an Upsert operation using the Repository pattern, is there a better approach for creating index then the one given below (may be using the fluent API?)

using (var db = new LiteRepository(dbSource))
{
db.Database.GetCollection<UserDTO>("Users").EnsureIndex(x => x.Email, true);
db.Upsert(User, "Users");  
}

jeshwel avatar Oct 20 '19 13:10 jeshwel

Hi @jeshwel, there is not other way to create indexes in Repository class.... I will think about adding this... thanks!

mbdavid avatar Oct 23 '19 13:10 mbdavid

Thanks @mbdavid , if you can add this as an attribute like [BsonRef] or as part of the Fluent mapper Api it would be cool :)

jeshwel avatar Oct 25 '19 10:10 jeshwel

Hi @mbdavid, is this possible yet? Or any plans to do this in the future?

I find the current way of setting up indexes quite un-intuitive.

I think it would be great to be able to define indexes through attributes or in a fluent configuration way, instead of always calling EnsureIndex.

1nfected avatar Jul 05 '23 08:07 1nfected

@mbdavid maybe can Add A Attribute to do that.

sgf avatar Jan 09 '24 05:01 sgf