public ImportStaticDataForm(nHydrate.Dsl.Entity entity, Microsoft.VisualStudio.Modeling.Store store, Microsoft.VisualStudio.Modeling.Shell.ModelingDocData docData) : this() { _entity = entity; _store = store; lblWelcome.Text = "This wizard will walk you through the process of import static data from a database entity. The database entity schema must match the target function '" + entity.Name + "' in the modelRoot."; this.DatabaseConnectionControl1.FileName = Path.Combine((new FileInfo(docData.FileName)).DirectoryName, "importconnection.cache"); DatabaseConnectionControl1.LoadSettings(); }
public static bool IsDerivedFrom(this nHydrate.Dsl.Entity entity, Entity parent) { var p = entity.ParentInheritedEntity; while (p != null) { if (p == parent) { return(true); } p = p.ParentInheritedEntity; } return(false); }
protected override void OnMenuPaste(object sender, global::System.EventArgs args) { nHydrateModel model = null; try { nHydrateDiagram diagram = null; nHydrate.Dsl.Entity selectedEntity = null; foreach (var item in this.CurrentSelection) { if (diagram == null && item is nHydrateDiagram) { diagram = item as nHydrateDiagram; } if (diagram == null && item is Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement) { diagram = (item as Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement).Diagram as nHydrateDiagram; if (item is EntityShape) { selectedEntity = (item as EntityShape).ModelElement as nHydrate.Dsl.Entity; } } } if (diagram != null) { model = diagram.ModelElement as nHydrateModel; model.IsLoading = true; } var beforeList = model.Entities.ToList(); base.OnMenuPaste(sender, args); var afterList = model.Entities.ToList().Except(beforeList).ToList(); #region Check indexes after Entity paste to make sure they are setup foreach (var item in afterList) { try { var settings = Extensions.FromXml <CopyStateSettings>(item.CopyStateInfo); using (var transaction = item.Store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString())) { //Now reset all indexes item.Indexes.Clear(); foreach (var indexDef in settings.Indexes) { var newIndex = item.Indexes.AddNew() as nHydrate.Dsl.Index; newIndex.Clustered = indexDef.Clustered; newIndex.IsUnique = indexDef.IsUnique; newIndex.Summary = indexDef.Summary; newIndex.IndexType = indexDef.IndexType; foreach (var columnDef in indexDef.Columns) { var newColumn = newIndex.IndexColumns.AddNew() as IndexColumn; newColumn.Ascending = columnDef.Acending; var fieldRef = item.FieldList.FirstOrDefault(x => x.Name == columnDef.Name); if (fieldRef != null) { newColumn.FieldID = (fieldRef as Microsoft.VisualStudio.Modeling.ModelElement).Id; } } } transaction.Commit(); } } catch (Exception ex) { } } #endregion #region We have pasted some fields so verify indexes //THIS DOES NOT WORK. NEED TO SAVE FIELDS BEFORE/AFTER AND COMPARE //if (afterList.Count == 0 && this.CurrentSelection.Count == 1 && selectedEntity != null) //{ // var item = selectedEntity; // using (var transaction = item.Store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString())) // { // foreach (Field field in item.FieldList) // { // if (field.IsIndexed) // { // if (!item.Indexes.Any(x => x.FieldList.Any(z => z.Id == field.Id) && x.IndexType == IndexTypeConstants.IsIndexed)) // { // var newIndex = item.Indexes.AddNew() as nHydrate.Dsl.Index; // newIndex.Clustered = false; // newIndex.IsUnique = false; // newIndex.IndexType = IndexTypeConstants.IsIndexed; // var newColumn = newIndex.IndexColumns.AddNew() as IndexColumn; // newColumn.Ascending = true; // newColumn.FieldID = field.Id; // } // } // } // transaction.Commit(); // } //} #endregion } catch (Exception ex) { throw; } finally { if (model != null) { model.IsLoading = false; } } }
// Constructors were not generated for this relationship because it had HasCustomConstructor // set to true. Please provide the constructors below in a partial class. // /// <summary> /// Constructor /// Creates a EntityInheritsEntity link in the same Partition as the given Entity /// </summary> /// <param name="source">Entity to use as the source of the relationship.</param> /// <param name="target">Entity to use as the target of the relationship.</param> public EntityInheritsEntity(Entity source, Entity target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[] { new DslModeling::RoleAssignment(EntityInheritsEntity.ChildDerivedEntitiesDomainRoleId, source), new DslModeling::RoleAssignment(EntityInheritsEntity.ParentInheritedEntityDomainRoleId, target) }, null) { this.InternalId = Guid.NewGuid(); }