Question

Breeze seems to be creating a very large file considering the object model I am passing it to save.

I am only saving one instance of a drug with 1 Drug option with 1 available route and some text fields with a single word in each.

When I grab the bundle from debug.breeze.js from line 14705 and save it to a text file the file is 35+ mb. This seems like an aweful lot of data for this straight forward object model.

Is there any way to slim down the json with just the objects? So I don't have to alter the IIS settings?

****************** Link to exported json that breeze is sending to the server ***********

Sample of json that's causing the problem

****************Here is a screen shot of the graph *************

Entire Graph

Drug Graph Item

Solid Option Graph Item

Available Solid Route

my datacontext.saveChanges code......

       function saveDictionaryChanges(entity) {
            var graph = manager.getEntityGraph(entity,  'drugIndications, ' +
                  'drugOptions, ' +
                  'drugOptions.concentrations, ' +
                  'drugOptions.availableRoutes, ' +
                  'drugOptions.availableDrugForms, ' +
                  'drugOptions.availableUnits');

        // Filter for changes only  
        graph = graph.filter(function (entity) {
            return entity.entityAspect.entityState.isAddedModifiedOrDeleted();
        });

        return manager.saveChanges(graph)
            .then(saveSucceeded, saveFailed);


        function saveSucceeded(result) {
            //TODO: Commented out because WIP is on the back burner
            //zStorage.save();


            logSuccess('Saved Data', result, true);
        }

        function saveFailed(error) {
            var msg = config.appErrorPrefix + 'Save failed: ' +
                breeze.saveErrorMessageService.getErrorMessage(error);
            error.message = msg;

            logError(msg, error);
            throw error;

        }

    }

my object model is

There are 4 other inherited available route types liquid,inhalation,injectable and topical. I only included AvailableSolidRoutes to help shorten he question.

     public class AvailableRoute {
        public int Id { get; set; }
        public int DrugOptionId { get; set; }
        public int RouteId { get; set; }
       public virtual Route Route { get; set; }
     }

    public class AvailableSolidRoute : AvailableRoute {
       public AvailableSolidRoute( ) { }
    }

There is also a Inhalation,Injectable & topical concentration object that inherit from concentration. I've only include LiquidConcentration to help shorten the question.

   public abstract class Concentration {        
          public int Id { get; set; }
          public int DrugOptionId { get; set; }
          public DrugOption DrugOption { get; set; }
          public decimal Measure{ get; set; }
          public int MassUnitId { get; set; }
          public virtual Unit MassUnit { get; set; }
          public int VolumeUnitId { get; set; }
          public virtual Unit VolumeUnit { get; set; }
          public int? DrugFormId { get; set; }
          public virtual DrugForm DrugForm { get; set; }        
          public int DisplayOrder { get; set; }             
   }

   public class LiquidConcentration : Concentration {
      public LiquidConcentration( ) {}
   }

There 4 other inherited types like solid option Liquid,Inhalation,Injectable & Topical

   public class DrugOption {
         public int Id { get; set; }
         public int DrugId { get; set; }
         public Drug Drug { get; set; }  

         public List<AvailableDrugForm> AvailableDrugForms { get; set; }
         public List<AvailableRoute> AvailableRoutes{ get; set; }
         public List<AvailableUnit> AvailableUnits { get; set; }
         public List<Concentration> Concentrations { get; set; }
         public string SpecialInstructions { get; set; }
   }

   public class SolidOption : DrugOption  {
         public SolidOption( ) { }
   }

Drug is the root class that all the previous classes relate to:

   public class Drug {
          public int Id { get; set; }
          public string Name { get; set; }
          public string Alias{ get; set; }
          public string Directions { get; set; }
          public bool DirectionsIsEditable { get; set; }
          public string SpecialDirections { get; set; }
          public bool SpecialDirectionsIsEditable { get; set; }
          public int? DisplayOrder { get; set; }
          public IList<DrugIndication> DrugIndications { get; set; }
          public IList<DrugOption> DrugOptions { get; set; }

         public Drug( ) { }
  }
Was it helpful?

Solution

***************** I fixed this issue (Was self induced hehe!) *************
So in order to make it easier to bind my "DrugOptions" to the UI. I created clientside properties on the drug for each type of drug options.

I did not understand what this code was actually doing.. I added it thinking it would remove the clientside property before sending entity changes to breeze. That is not it's purpose.

Rightly so breeze was confused about the clientside properties because it does not know about them.

        if (changedProp === 'solidOption') {
            delete changeArgs.entity.entityAspect.originalValues[changedProp];
        }

I moved these properties to the Controller and it's perfectly fine now :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top