Reputation: 423
Does ServiceStack.OrmLite support attributes using Linq like in EntityFramework?
Instead of decorating every property with [PrimaryKey] or [CustomField], have a initializer class that uses LinQ to set-up attributes for every property.
Something like
Entity<User>().SetCustomField(p => p.Id, Entity.PrimaryKey);
Possible?
Upvotes: 0
Views: 338
Reputation: 143339
In OrmLite Id
is automatically the Primary Key, otherwise the first property is assumed to be the primary key. But you can also use ServiceStack's dynamic attribute API to add attributes dynamically on StartUp, e.g:
typeof(User)
.GetProperty("Id")
.AddAttributes(new PrimaryKeyAttribute());
Upvotes: 2