-
Type: Task
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.0
-
Component/s: Feature Request
It would be great if I could mark a class with an attribute so that the C# driver knows it needs to load/fetch (a join) additional documents without having to hand code this each time:
–
class Order
{
[BsonReference("db.users", "_id", "UserId)]
public User User
...
}
- Or lazy loading -
class Order
{
[BsonReference("db.users", "_id", "UserId)]
public Reference<User> User {get;set;}
...
}
–
In both examples, I indicate that this Order class (that the driver knows about due to mappings) has a User property that I would like to be loaded each time an Order is loaded as well. Let the driver load this on my behalf.
The first version would always load the property, the second would lazy load for me - accessing the order.User property would lazy load the proxy in the background (the driver would fetch the instance for me).
I'd like to avoid having to use a 'DBRef' in this case because the relationship is obvious (its always going to be a User I want loaded, found in the db.users collection).
I also want to avoid using the 'FollowReference' syntax because it means I can't just use order.User I need to put a UserId on the Order instance (which is a bit unclean) and would rather be able to access the object directly (while being aware its going to cost in terms of performance).
Thoughts?
- Andrew
- is related to
-
CSHARP-232 Create DBRefs with conventions
- Closed