private void PopulateInfoIntoDescriptor(RelationshipInfo info, ActiveRecordPropertyRelationDescriptor desc) { desc.Insert = info.Insert; desc.Update = info.Update; desc.Inverse = info.Inverse; desc.Proxy = info.UseProxy; desc.Cascade = info.Cascade; desc.OuterJoin = info.OuterJoin; desc.Where = info.Where; desc.OrderBy = info.OrderBy; }
private ActiveRecordPropertyRelationDescriptor CreateHasManyRelation(RelationshipInfo info) { // Validates first if (info.ChildCol == null) { throw new ArgumentException("No column specified"); } String colName = info.ChildCol.Name; String propName = _namingService.CreateRelationName(info.TargetDescriptor.ClassName); return(new ActiveRecordHasManyDescriptor(colName, propName, info.TargetDescriptor)); }
private ActiveRecordPropertyRelationDescriptor CreateBelongsToRelation(RelationshipInfo info) { // Validates first if (info.ParentCol == null) { throw new ArgumentException("No parent column specified"); } String colName = info.ParentCol.Name; String propName = info.TargetDescriptor.ClassName; return(new ActiveRecordBelongsToDescriptor(colName, propName, info.TargetDescriptor)); }
private ActiveRecordPropertyRelationDescriptor CreateHasManyRelation(RelationshipInfo info) { // Validates first if (info.ChildCol == null) { throw new ArgumentException("No column specified"); } String colName = info.ChildCol.Name; String propName = _namingService.CreateRelationName( info.TargetDescriptor.ClassName ); return new ActiveRecordHasManyDescriptor(colName, propName, info.TargetDescriptor); }
private ActiveRecordPropertyRelationDescriptor CreateBelongsToRelation(RelationshipInfo info) { // Validates first if (info.ParentCol == null) { throw new ArgumentException("No parent column specified"); } String colName = info.ParentCol.Name; String propName = info.TargetDescriptor.ClassName; return new ActiveRecordBelongsToDescriptor(colName, propName, info.TargetDescriptor); }
public ActiveRecordPropertyRelationDescriptor Build(RelationshipInfo info) { ActiveRecordPropertyRelationDescriptor desc = null; if (info.Association == AssociationEnum.BelongsTo) { desc = CreateBelongsToRelation(info); } else if (info.Association == AssociationEnum.HasMany) { desc = CreateHasManyRelation(info); } else if (info.Association == AssociationEnum.HasAndBelongsToMany) { desc = CreateHasManyAndBelongsToRelation(info); } PopulateInfoIntoDescriptor(info, desc); return(desc); }
public ActiveRecordPropertyRelationDescriptor Build(RelationshipInfo info) { ActiveRecordPropertyRelationDescriptor desc = null; if (info.Association == AssociationEnum.BelongsTo) { desc = CreateBelongsToRelation(info); } else if (info.Association == AssociationEnum.HasMany) { desc = CreateHasManyRelation(info); } else if (info.Association == AssociationEnum.HasAndBelongsToMany) { desc = CreateHasManyAndBelongsToRelation(info); } PopulateInfoIntoDescriptor(info, desc); return desc; }
private void okButton_Click(object sender, System.EventArgs e) { if (_association == AssociationEnum.Undefined) { cancelButton_Click(sender, e); return; } try { RelationshipInfo info = new RelationshipInfo(_association, _descriptor, SelectedTarget); info.ParentCol = SelectedParentCol; info.ChildCol = SelectedRelatedCol; info.AssociationTable = SelectedAssociationTable; info.Where = where.Text; info.OrderBy = order.Text; info.OuterJoin = outerJoin.Text; // TODO: Add checkbox for proxy info.UseProxy = false; info.Insert = insertButton.Checked; info.Update = updateButton.Checked; info.Lazy = lazyButton.Checked; info.Cascade = cascade.SelectedText; ActiveRecordPropertyRelationDescriptor prop = _relationBuilder.Build( info ); _descriptor.PropertiesRelations.Add(prop); } catch(Exception ex) { String message = String.Format("Something is missing... \r\n\r\n{0}", ex.Message); MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult = DialogResult.OK; }
private ActiveRecordPropertyRelationDescriptor CreateHasManyAndBelongsToRelation(RelationshipInfo info) { // Validates first if (info.ParentCol == null) { throw new ArgumentException("No parent column specified"); } if (info.ChildCol == null) { throw new ArgumentException("No child column specified"); } if (info.AssociationTable == null) { throw new ArgumentException("No association table specified"); } String colName = info.ChildCol.Name; String colKeyName = info.ParentCol.Name; String propName = _namingService.CreateRelationName(info.TargetDescriptor.ClassName); return(new ActiveRecordHasAndBelongsToManyDescriptor(colName, info.AssociationTable.Name, propName, info.TargetDescriptor, colKeyName)); }
private ActiveRecordPropertyRelationDescriptor CreateHasManyAndBelongsToRelation(RelationshipInfo info) { // Validates first if (info.ParentCol == null) { throw new ArgumentException("No parent column specified"); } if (info.ChildCol == null) { throw new ArgumentException("No child column specified"); } if (info.AssociationTable == null) { throw new ArgumentException("No association table specified"); } String colName = info.ChildCol.Name; String colKeyName = info.ParentCol.Name; String propName = _namingService.CreateRelationName( info.TargetDescriptor.ClassName ); return new ActiveRecordHasAndBelongsToManyDescriptor(colName, info.AssociationTable.Name, propName, info.TargetDescriptor, colKeyName); }