private IOrganizationService GetService(IExecutionContext context) { var result = this.client ?? (this.client = new CrmServiceClient(this.connectionString ?? (string)context.GetDefault("connectionstring", this))); if (!result.IsReady) { throw new Exception($"Unable to connect to CRM: {result.LastCrmError}."); } return(result); }
/// <summary> /// Retrieves the data from multiple sources as an <see cref="IAsyncEnumerable{T}"/>. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="rowBuilder"> /// The row builder. /// </param> /// <param name="query"> /// The join query expression. Can be <c>null</c>. /// </param> /// <returns> /// A task returning the data set. /// </returns> IAsyncEnumerable <Row> ISupportsJoin.GetRows(IExecutionContext context, IRowBuilder rowBuilder, IJoinQuery query) { throw new NotSupportedException("Join support is not yet implemented."); }
/// <summary> /// Retrieves the data from the source as an <see cref="T:ConnectQl.AsyncEnumerables.IAsyncEnumerable`1" />. /// </summary> /// <param name="context">The context.</param> /// <param name="rowBuilder">The row builder.</param> /// <param name="query">The query expression. Can be <c>null</c>.</param> /// <returns> /// A task returning the data set. /// </returns> public IAsyncEnumerable <Row> GetRows(IExecutionContext context, IRowBuilder rowBuilder, IQuery query) { this.GetQueryExpression(query.GetFilter(context)); return(context.CreateEmptyAsyncEnumerable <Row>()); }
/// <summary> /// Checks if this data source supports the join query. /// </summary> /// <param name="context"> /// The execution context. /// </param> /// <param name="query"> /// The query to check. /// </param> /// <returns><c>true</c> if the <see cref="ISupportsJoin"/> supports the specified <paramref name="query"/>, <c>false</c> otherwise.</returns> bool ISupportsJoin.SupportsJoinQuery(IExecutionContext context, IJoinQuery query) { return(false); }
/// <summary> /// Gets the descriptor for this data source. /// </summary> /// <param name="sourceAlias">The data source source alias.</param> /// <param name="context">The execution context.</param> /// <returns> /// The <see cref="T:System.Threading.Tasks.Task" />. /// </returns> public async Task <IDataSourceDescriptor> GetDataSourceDescriptorAsync(string sourceAlias, IExecutionContext context) { return(await Task.Run(() => { var metadata = ((RetrieveEntityResponse)this.GetService(context).Execute(new RetrieveEntityRequest { LogicalName = this.entityName, EntityFilters = EntityFilters.Attributes })).EntityMetadata; return Descriptor.ForDataSource( sourceAlias, metadata.Attributes.Select(a => Descriptor.ForColumn(a.LogicalName, EntityDataSource.ToType(a.AttributeType), a.DisplayName?.UserLocalizedLabel?.Label)).Where(a => a.Type != null)); })); }