Something Odd is happening, even though I created a new object to add to the list in the using statement, it seems to be self referencing, the second time it loops through its adding the same object even though i created a new one and the objects inside are compounding.
So at the end i have 7 identical XMLMachiningModel's in the list each containing 42 objects in the Layout, it should be 7 different XMLMachiningModel's each containing 6 Objects in the Layouts
I have no idea why, can anybody suggest a solution or a path to investigate
Thanks
Madaxe
		
		
	
	
		 
	
		 
	
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			So at the end i have 7 identical XMLMachiningModel's in the list each containing 42 objects in the Layout, it should be 7 different XMLMachiningModel's each containing 6 Objects in the Layouts
I have no idea why, can anybody suggest a solution or a path to investigate
Thanks
Madaxe
			
				C#:
			
		
		
		        public MemoryStream GetReaJetXMLZips(IEnumerable<JsonRequestModel> JsonRequestModels=null)
        {
            MemoryStream ReturnMemoryStream = null;
            //For Testing Locally Only
            if (JsonRequestModels == null){JsonRequestModels = this.GetTestXMLRequest();}
            foreach(JsonRequestModel JsonRequestModel in JsonRequestModels)
            {
                // Build MySQL In List
                string MySQLInPartNumbers = string.Concat(String.Join("','", JsonRequestModel.slatPartNumbers.Select(i => i.ToString()).ToArray()));
               
                // Build The XML Structures
                IEnumerable<SlatModel> SlatModel = this._NewRepo.GetSlatModels(MySQLInPartNumbers);
                using (XMLMachiningModel NewXMLMachiningModel = this.BuildSlatsXML(SlatModel, MySQLInPartNumbers))
                {
                    this.UpdateOneOffObjects(NewXMLMachiningModel);
                    this.BuildConnectionObjects(NewXMLMachiningModel, MySQLInPartNumbers);
                    this._XMLMachiningModels.Add(NewXMLMachiningModel);
                }
            }
            // Serialize the XMLs and Add to Zip Files
            ReturnMemoryStream = this.BuildRootZip();
            ReturnMemoryStream.Seek(0, SeekOrigin.Begin);
            return ReturnMemoryStream;
        }
        private XMLMachiningModel BuildSlatsXML(IEnumerable<SlatModel> iSlatModelsList, string iMySQLInPartNumbers)
        {
            XMLMachiningModel ReturnXMLMachiningModel = new XMLMachiningModel(this._NewRepo, iSlatModelsList);
            ReturnXMLMachiningModel.ReaJetSideBase = BuildReaJetSideBaseXMLMachiningModel(iSlatModelsList, iMySQLInPartNumbers);
            ReturnXMLMachiningModel.ReaJetTopLeftBase = BuildReaJetTopLeftBaseXMLMachiningModel(iSlatModelsList, iMySQLInPartNumbers);
            ReturnXMLMachiningModel.ReaJetTopRightBase = BuildReaJetTopRightBaseXMLMachiningModel(iSlatModelsList, iMySQLInPartNumbers);
            ReturnXMLMachiningModel.SetMachiningLength(iSlatModelsList, iMySQLInPartNumbers);
            return ReturnXMLMachiningModel;
        } 
	 
					
				 
 
		 
 
		