//NEXT: Implement namedResource to insert image
        public static void InsertEntityTableXml(this word.Range range, IEnumerable<IEnumerable<EntityProperty>> entityProperties, 
            string styleName, string namedResource)
        {
            SdtCell contentControl = null;
            TableRow row = null;
            int incrementor = 1;

            Stream packageStream = range.GetPackageStreamFromRange();

            List<string> propertyNames =
            (from item in entityProperties select item).First<IEnumerable<EntityProperty>>()
                .Where(n => n.Type != "Edm.Stream" && n.Name != "id").Select(n => n.Name).ToList<string>();

            int columnCount = propertyNames.Count();
            int rowCount = entityProperties.Count();

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(packageStream, true))  
            {
                //Remove all children 
                wordDoc.MainDocumentPart.Document.Body.RemoveAllChildren();
                //Generate table markup. 
                Table table = new Table();
                
                //Data Columns
                row = new TableRow();                    
                foreach (string name in propertyNames)
                {
                    incrementor++;
                    contentControl = GenerateSdtCell(name, name, name, incrementor);

                    row.AppendChild<SdtCell>(contentControl);
                        
                }
                table.AppendChild<TableRow>(row);
                
                //Data Values
                //Reset incrementor
                incrementor = 1;

                foreach (IEnumerable<EntityProperty> items in entityProperties)
                {
                    //For this sample, add namedResource to ContentControl tag
                    string tag = string.Format("{0}/#{1}",
                        (from p in items where p.Name == "id" select p.Value).First().ToString(), namedResource);

                    row = new TableRow();

                    foreach (EntityProperty item in items)
                    {
                        //For this sample, ignore link.image/gif and id
                        //See the Ribbon sample for how to used named resources
                        if (item.Type != "Edm.Stream" && item.Name != "id")
                        {
                            incrementor++;
                            contentControl = GenerateSdtCell(item.Name, item.Value.ToString(), tag, incrementor);

                            row.AppendChild<SdtCell>(contentControl);
                        }
                    }
                    table.AppendChild<TableRow>(row);
                }

                wordDoc.MainDocumentPart.Document
                    .Body
                    .AppendChild<Table>(table);

                wordDoc.MainDocumentPart.Document.Save();
                //Flush the contents of the package 
                wordDoc.Package.Flush();
                //Convert back to flat opc using this in-memory package 
                XDocument xDoc = OpcHelper.OpcToFlatOpc(wordDoc.Package);

                range.Application.ScreenUpdating = false;
                //Insert this flat opc Xml 
                range.InsertXML(xDoc.ToString());

                try
                {
                    range.Tables[1].set_Style(styleName);
                }
                catch
                { 
                    //Catch a specific exception in a production application
                }
                range.Application.ScreenUpdating = true;
            } 
        }