Storing collections

Mar 20, 2015 at 1:40 AM
I'm experimenting with nonSQL databases and BrightstarDB. I'm trying to create a sample ordering database.

I created an order details class:
    public interface IOrderItem
    {
        string Id { get; }

        string prodDescription { get; set; }
        string prodSKU { get; set; }
        int prodQuantity { get; set; }
    }
and I tried to create an order class:
    public interface IOrder
    {
        string Id { get; }

        Guid customerID { get; set; }
        Guid orderID { get; set; }
        string orderNumber { get; set; }
        DateTime orderDate { get; set; }

        List<IOrderItem> orderItems:
    }
But, when I do "Run Custom Tool" on the MyEntityContext.tt file, I get this error message:

Running transformation: Invalid property: MyTest.IOrder.orderItems - the property type System.Collections.Generic.List<MyTest.IOrderItem> is not supported by Entity Framework.

If I comment out the List property from IOrder, the error goes away, so it's obviously associated with my attempt to declare the list.

I haven't been able to find any postings that talks about how to include a collection in an object in BrightstarDB.

I suppose I could include the orderID in IOrderItem and store the individual IOrderItem records separately from the parent IOrder record. Is this the approach I need to take? I would appreciate if someone can help enlighten me as to the right approach to take.

Thanks,

Richard
Coordinator
Mar 20, 2015 at 10:34 AM
You just need to declare your collection as an ICollection<T> rather than as a List<T> - the generated code will implement the ICollection interface.

Take a look at http://brightstardb.readthedocs.org/en/latest/Entity_Framework/#patterns for more information and other data patterns.

Hope this helps!

Kal
Marked as answer by rrosenheim on 3/24/2015 at 4:27 PM
Mar 24, 2015 at 11:27 PM
Thanks! That was the trick. I tried IList, but never thought of using ICollection.

Richard