locked
Check if VisualCollection is dirty RRS feed

  • Question

  • I know how to check to see if an individual record is dirty as in:
    if (this.DistrictProperty.Details.EntityState != EntityState.Unchanged) { ... }

    I see that lists on a screen are of type Microsoft.LightSwitch.Framework.Client.VisualCollection<type>. Does anybody have any idea how to check to see if any records in this collection is dirty?


    Bruce


    Friday, May 31, 2013 7:33 PM

Answers

  • Hi,

    The Visual Collection does not keep track of those information. But you can enumerate through the values and find out. For example:

    var hasChangedOrders = this.Orders.Any(
        o => o.Details.EntityState == EntityState.Added || 
             o.Details.EntityState == EntityState.Deleted || 
             o.Details.EntityState == EntityState.Modified);

    Also, the Data Service is the one keeping track of changed entities for the entire screen. For example:

    var changeSet = this.DataWorkspace.ApplicationData.Details.GetChanges();
    var addedEntities = changeSet.AddedEntities;
    var deletedEntities = changeSet.DeletedEntities;
    var modifiedEntities = changeSet.ModifiedEntities;

    Best regards,
    Huy


    Wednesday, June 5, 2013 12:16 AM

All replies

  • Hi,

    The Visual Collection does not keep track of those information. But you can enumerate through the values and find out. For example:

    var hasChangedOrders = this.Orders.Any(
        o => o.Details.EntityState == EntityState.Added || 
             o.Details.EntityState == EntityState.Deleted || 
             o.Details.EntityState == EntityState.Modified);

    Also, the Data Service is the one keeping track of changed entities for the entire screen. For example:

    var changeSet = this.DataWorkspace.ApplicationData.Details.GetChanges();
    var addedEntities = changeSet.AddedEntities;
    var deletedEntities = changeSet.DeletedEntities;
    var modifiedEntities = changeSet.ModifiedEntities;

    Best regards,
    Huy


    Wednesday, June 5, 2013 12:16 AM
  • That is exactly what I need. Thanks!

    Bruce

    Wednesday, June 5, 2013 2:53 PM