public void LinkEntry(string tableName, IDictionary <string, object> entryKey, string linkName, IDictionary <string, object> linkedEntryKey) { var association = _schema.FindTable(tableName).FindAssociation(linkName); var command = CreateLinkCommand(tableName, linkName, FormatGetKeyCommand(tableName, entryKey), FormatGetKeyCommand(association.ReferenceTableName, linkedEntryKey)); _requestBuilder.AddCommandToRequest(command); _requestRunner.UpdateEntry(command); }
/// <summary> /// Invoked when a get memebr operation is resolved dynamically. /// </summary> /// <param name="binder">Provides information about the operation to execute.</param> /// <param name="result">Holder for the result of the operation.</param> /// <returns>True if the operation executed successfully, false otherwise.</returns> public override bool TryGetMember(GetMemberBinder binder, out object result) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (_Schema == null) { throw new InvalidOperationException("This '{0}' is not associated with any schema.".FormatWith(this)); } var list = _Schema.FindTable(binder.Name).ToList(); if (list.Count != 0) { result = new RecordResolver(this, binder.Name); list.Clear(); list = null; return(true); } list = _Schema.FindColumn(binder.Name).ToList(); if (list.Count == 1) { result = this[binder.Name]; list.Clear(); list = null; return(true); } if (list.Count == 0) { throw new NotFoundException("Column '{0}' not found.".FormatWith(binder.Name)); } throw new DuplicateException("Dynamic name '{0}' found in several columns in '{1}'.".FormatWith(binder.Name, list.Sketch())); }
/// <summary> /// Invoked when a get memebr operation is resolved dynamically. /// </summary> /// <param name="binder">Provides information about the operation to execute.</param> /// <param name="result">Holder for the result of the operation.</param> /// <returns>True if the operation executed successfully, false otherwise.</returns> public override bool TryGetMember(GetMemberBinder binder, out object result) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } var list = _Schema.FindTable(binder.Name).ToList(); if (list.Count != 0) { result = new RecordBuilderResolver(this, binder.Name); list.Clear(); list = null; return(true); } list = _Schema.FindColumn(binder.Name).ToList(); if (list.Count == 1) { result = this[binder.Name]; list.Clear(); list = null; return(true); } if (list.Count == 0) { result = new RecordBuilderResolver(this, binder.Name); return(true); } throw new DuplicateException( "Column '{0}' found in several columns in '{1}'.".FormatWith(binder.Name, this)); }
public IList <string> GetKeyNames() { return(_schema.FindTable(_actualName).PrimaryKey.AsEnumerable().ToList()); }