Are records uploaded to a HashSet or SortedSet linked?

Suppose we have a POCO class for Entity Framework 4:

public class Order
{
    public long Id { get; set; }
    public ISet<OrderItem> OrderItems { get; set; }
}

And this method to retrieve the order from the database:

public Order GetOrder(long orderId)
{
    using (var context = new MyModelEntities())
    {
        return context.Orders.Include("OrderItems").Where(order => order.Id == orderId).FirstOrDefault();
    }
}

So, suppose we do this:

Order myOrder = GetOrder(1);

Is myOrder.OrderItems a HashSet or SortedSet? Is there any way to control this?

+3
source share
1 answer

Good question.

As far as I know (and there is no MSDN / blog / article, I know that this waves / proves it), the navigation property can be of any type if it implements ICollection<T>.

Both HashSet<T>and SortedSet<T>implement ICollection<T>, so either be viable candidates.

Did you go through the code? You should be able to see which particular class will be resolved.

ICollection<T>/IList<T>. ISet<T>?

, , .

(For<ISet>().Use<HashSet>()).

+3

Source: https://habr.com/ru/post/1785842/


All Articles