The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Adding Entity Objects to an Entity Collection

Last post 07-24-2008, 1:22 PM by David.Parsons. 2 replies.
Sort Posts: Previous Next
  •  07-24-2008, 11:28 AM 10367

    Adding Entity Objects to an Entity Collection

    High - we're evaluating the product and so far have only a few complaints.  One of them is as follows.  I'll post the other's separately. 

    Is there an easy way to add an group of entity objects to a collection?  I want to do something like the following

    Dim col as new bpSecondParentCollection

    for each filter as bpPostFilter in postFilters

    col.add(filter.upToFirstParent.UpToSecondParent)

    end for

    return col

    Seems like this would be fairly straight forward.  Before you suggest it, I do not want to use AddNew, as this is collection is not meant to be updated

  •  07-24-2008, 12:26 PM 10370 in reply to 10367

    Re: Adding Entity Objects to an Entity Collection

    Hi

    You can use the xxxCollection.Combine(yyyCollection) method for that - so in your example:

    col.Combine(filter.upToFirstParent.UpToSecondParent)

    should do the trick

    Cheers

    Martin

  •  07-24-2008, 1:22 PM 10373 in reply to 10367

    Re: Adding Entity Objects to an Entity Collection

    For individual entities, you can also use the collection's AttachEntity/DetachEntity methods.

    Code:
    OrdersCollection filter = new OrdersCollection();
    filter.Query.Where(filter.Query.CustomerID.Like("A%"));
    filter.Query.Load();
    
    EmployeesCollection collection = new EmployeesCollection();
    
    foreach (Orders ord in filter)
    {
        if (collection.FindByPrimaryKey(
            ord.UpToEmployeesByEmployeeID.EmployeeID.Value) == null)
        {
            collection.AttachEntity(ord.UpToEmployeesByEmployeeID);
        }
    }

    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML