示例#1
0
        protected override void ProcessOnMenuCopyCommand()
        {
            try
            {
                var diagram = (this.CurrentModelingDocView as Microsoft.VisualStudio.Modeling.Shell.SingleDiagramDocView).Diagram;
                foreach (EntityShape shape in this.CurrentDocumentSelection.ToList <object>().Where(x => x is EntityShape).ToList())
                {
                    using (var transaction = shape.Store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString()))
                    {
                        var entity = shape.ModelElement as Entity;
                        var cache  = new CopyStateSettings();

                        foreach (var item in entity.Indexes)
                        {
                            var indexCache = new CopyStateSettings.CopyStateIndex
                            {
                                Clustered = item.Clustered,
                                IsUnique  = item.IsUnique,
                                Summary   = item.Summary,
                                IndexType = item.IndexType,
                            };
                            cache.Indexes.Add(indexCache);

                            foreach (var col in item.IndexColumns)
                            {
                                indexCache.Columns.Add(new CopyStateSettings.CopyStateIndexColumn
                                {
                                    Acending = col.Ascending,
                                    Name     = col.Field.Name,
                                });
                            }
                        }

                        var xml = Extensions.ToXml(cache);
                        entity.CopyStateInfo = xml;
                        transaction.Commit();
                    }
                }

                base.ProcessOnMenuCopyCommand();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#2
0
        protected override void ProcessOnMenuCopyCommand()
        {
            try
            {
                var diagram = (this.CurrentModelingDocView as Microsoft.VisualStudio.Modeling.Shell.SingleDiagramDocView).Diagram;
                foreach (EntityShape shape in this.CurrentDocumentSelection.ToList<object>().Where(x => x is EntityShape).ToList())
                {
                    using (var transaction = shape.Store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString()))
                    {
                        var entity = shape.ModelElement as Entity;
                        var cache = new CopyStateSettings();

                        foreach (var item in entity.Indexes)
                        {
                            var indexCache = new CopyStateSettings.CopyStateIndex
                            {
                                Clustered = item.Clustered,
                                IsUnique = item.IsUnique,
                                Summary = item.Summary,
                                IndexType = item.IndexType,
                            };
                            cache.Indexes.Add(indexCache);

                            foreach (var col in item.IndexColumns)
                            {
                                indexCache.Columns.Add(new CopyStateSettings.CopyStateIndexColumn {
                                    Acending = col.Ascending,
                                    Name = col.Field.Name,
                                });
                            }
                        }

                        var xml = Extensions.ToXml(cache);
                        entity.CopyStateInfo = xml;
                        transaction.Commit();
                    }
                }

                base.ProcessOnMenuCopyCommand();
            }
            catch (Exception ex)
            {
                throw;
            }
        }