Relationship between entities
Closed this issue · 1 comments
gaui commented
When I'm setting up the entities I use these pseudo _X_value
attributes to reference other entities.
Isn't that possible to create relationship between entities?
For example:
var productId = Guid.NewGuid();
var product = new Entity
{
Id = productId,
LogicalName = "product"
};
var carId = Guid.NewGuid();
var car = new Entity
{
Id = carId,
LogicalName = "car",
Attributes =
{
["_productid_value"] = productId
}
};
Or do I have to do:
var productId = Guid.NewGuid();
var product = new Entity
{
Id = productId,
LogicalName = "product"
};
var carId = Guid.NewGuid();
var car = new Entity
{
Id = carId,
LogicalName = "car",
Attributes =
{
["productid"] = product.ToEntityReference()
}
};
jordimontana82 commented
You could just do:
var car = new Entity("car")
{
Id = carId,
["productid"] = product.ToEntityReference()
};
Although better if you could use early bound.