/// <summary> /// Executes the query provided by the SqlCommand object. /// Returns an object corresponding to QueryResultType /// </summary> /// <param name="queryCommand">SqlCommand object with query to be executed</param> /// <param name="resultType">QueryResultType to return</param> /// <param name="conn">The SqlConnection to execute the Command on</param> /// <returns> /// System.Object cast to QueryResultType value. /// Return types are: SqlDataReader, DataSet, System.Int, System.Object /// </returns> private static object ExecuteQuery(SqlCommand queryCommand, QueryResultType resultType, SqlConnection conn) { //Make sure we don't try to open an already-open connection if (conn.State != ConnectionState.Open) { conn.Open(); } queryCommand.Connection = conn; switch (resultType) { case QueryResultType.DataReader: return(queryCommand.ExecuteReader()); case QueryResultType.DataSet: { DataSet ds = new DataSet(); ds.Locale = CultureInfo.CurrentCulture; using (SqlDataAdapter da = new SqlDataAdapter()) { da.SelectCommand = queryCommand; da.Fill(ds); } return(ds); } case QueryResultType.Null: return(queryCommand.ExecuteNonQuery()); case QueryResultType.Scalar: return(queryCommand.ExecuteScalar()); default: throw new ArgumentOutOfRangeException("resultType", "resultType is not a valid QueryResultType"); } }
/// <summary> /// Executes the query provided by the SqlCommand object. /// Returns an object corresponding to QueryResultType /// </summary> /// <param name="queryCommand">SqlCommand object with query to be executed</param> /// <param name="resultType">QueryResultType to return</param> /// <returns> /// System.Object cast to QueryResultType value. /// Return types are: SqlDataReader, DataSet, System.Int, System.Object /// </returns> private static object ExecuteQuery(SqlCommand queryCommand, QueryResultType resultType) { using (SqlConnection conn = GetConnection) { return(ExecuteQuery(queryCommand, resultType, conn)); } }
public DocumentIndexSourceEntry( QueryResultType type, Path path, string title, Uri icon, string description) : base(type, title, description, icon) { Path = path; IsDirectory = type == QueryResultType.Folder; }
protected IndexedEntry(QueryResultType type, string title, string description, Uri icon) { Type = type; Title = title; Icon = icon; Description = description; }
public Object ProcessServiceResult(Object result, IList <IObjRef> objRefs, IList <Object> entities, Type expectedType, Object[] serviceRequestArgs, Attribute annotation) { IPagingResponse pagingResponse = (IPagingResponse)result; QueryResultType queryResultType = QueryResultType.REFERENCES; if (annotation is FindAttribute) { queryResultType = ((FindAttribute)annotation).ResultType; } switch (queryResultType) { case QueryResultType.BOTH: pagingResponse.RefResult = objRefs; pagingResponse.Result = entities; break; case QueryResultType.ENTITIES: pagingResponse.RefResult = null; pagingResponse.Result = entities; break; case QueryResultType.REFERENCES: pagingResponse.RefResult = objRefs; pagingResponse.Result = null; break; default: throw RuntimeExceptionUtil.CreateEnumNotSupportedException(queryResultType); } return(pagingResponse); }
public ObjectHistoryQueryResult(ObjectHistoryGlobalEntity objectHistoryGlobalEntity) { Folder = objectHistoryGlobalEntity.Folder; RowKey = objectHistoryGlobalEntity.RowKey; ObjectName = objectHistoryGlobalEntity.ObjectName; ModifiedBy = objectHistoryGlobalEntity.User; ModifiedDate = objectHistoryGlobalEntity.OriginTimestamp; QueryResultType = QueryResultType.Global; }
public ObjectHistoryQueryResult(string partitionKey, ObjectHistoryEntity objectHistoryEntity) { Folder = objectHistoryEntity.Folder; RowKey = objectHistoryEntity.RowKey; ObjectName = partitionKey; ApplicationName = objectHistoryEntity.ApplicationName; ModifiedBy = objectHistoryEntity.User; ModifiedDate = objectHistoryEntity.OriginTimestamp; QueryResultType = QueryResultType.Object; }
static IEnumerable <T> CastResultContent <T>(QueryResult result, QueryResultType expected) { if (result.Type != expected) { throw new InvalidCastException($"result type is {result.Type}"); } // TODO: optimize this 2nd parse from JObject to target object type T return(result.Items.Select(o => ((JObject)o).ToObject <T>())); }
public FileResult(QueryResultType type, Uri path, Uri icon, string title, string description, float distance, float score) { Type = type; Path = path; Icon = icon; Title = title; Description = description; Distance = distance; Score = score; }
/// <summary> /// Builds error response. /// </summary> /// <param name="ex"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception ex) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryRegistrationResponseType(); regInterface.QueryRegistrationResponse = returnType; V2Helper.Header = regInterface; var queryResult = new QueryResultType(); returnType.QueryResult.Add(queryResult); queryResult.timeSeriesMatch = false; var statusMessage = new StatusMessageType(); queryResult.StatusMessage = statusMessage; this.AddStatus(statusMessage, ex); return responseType; }
/// <summary> /// Evaluates the result status and creates a response message. /// </summary> /// <param name="responseMessage">The response message.</param> /// <param name="resultType">Type of the result.</param> /// <returns></returns> private static bool EvaluateResultStatus(out string responseMessage, QueryResultType resultType) { switch (resultType) { case QueryResultType.Inconclusive: responseMessage = $"Sorry I failed to understand your request."; return(true); case QueryResultType.NoMetalSpecified: responseMessage = $"It appears you did not specify a metal for me to query."; return(true); case QueryResultType.NonCostFocused: responseMessage = $"It appears you did not ask a question that is cost related."; return(true); } responseMessage = string.Empty; return(false); }
/// <summary> /// Executes the query provided by the SqlCommand object. /// Returns an object corresponding to QueryResultType /// </summary> /// <param name="queryCommand">SqlCommand object with query to be executed</param> /// <param name="resultType">QueryResultType to return</param> /// <returns> /// System.Object cast to QueryResultType value. /// Return types are: SqlDataReader, DataSet, System.Int, System.Object /// </returns> private static object ExecuteQuery(SqlCommand queryCommand, QueryResultType resultType) { using (SqlConnection conn = GetConnection) { return ExecuteQuery(queryCommand, resultType, conn); } }
async Task <IEnumerable <T> > GetAndCastNextResultAsync <T>(QueryResultType type) { QueryResult r = await GetNextAsync(); return(CastResultContent <T>(r, type)); }
/// <summary> /// The build success response. /// </summary> /// <param name="registrations"> /// The registrations. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ICollection<IRegistrationObject> registrations) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryRegistrationResponseType(); regInterface.QueryRegistrationResponse = returnType; V2Helper.Header = regInterface; if (!ObjectUtil.ValidCollection(registrations)) { var queryResult = new QueryResultType(); returnType.QueryResult.Add(queryResult); queryResult.timeSeriesMatch = false; var statusMessage = new StatusMessageType(); queryResult.StatusMessage = statusMessage; statusMessage.status = StatusTypeConstants.Warning; var tt = new TextType(); statusMessage.MessageText.Add(tt); tt.TypedValue = "No Registrations Match The Query Parameters"; } else { /* foreach */ foreach (IRegistrationObject currentRegistration in registrations) { var queryResult0 = new QueryResultType(); returnType.QueryResult.Add(queryResult0); var statusMessage1 = new StatusMessageType(); queryResult0.StatusMessage = statusMessage1; this.AddStatus(statusMessage1, null); queryResult0.timeSeriesMatch = false; // FUNC 1 - when is this true? Also We need MetadataResult var resultType = new ResultType(); queryResult0.DataResult = resultType; if (currentRegistration.DataSource != null) { IDataSource datasourceBean = currentRegistration.DataSource; var datasourceType = new DatasourceType(); resultType.Datasource = datasourceType; if (datasourceBean.SimpleDatasource) { datasourceType.SimpleDatasource = datasourceBean.DataUrl; } else { var queryableDatasource = new QueryableDatasourceType(); datasourceType.QueryableDatasource = queryableDatasource; queryableDatasource.isRESTDatasource = datasourceBean.RESTDatasource; queryableDatasource.isWebServiceDatasource = datasourceBean.WebServiceDatasource; queryableDatasource.DataUrl = datasourceBean.DataUrl; if (datasourceBean.WsdlUrl != null) { queryableDatasource.WSDLUrl = datasourceBean.WsdlUrl; } } } if (currentRegistration.ProvisionAgreementRef != null) { WriteProvisionAgreementRef(currentRegistration.ProvisionAgreementRef, resultType); } } } return responseType; }
/// <summary> /// Executes the query provided by the SqlCommand object. /// Returns an object corresponding to QueryResultType /// </summary> /// <param name="queryCommand">SqlCommand object with query to be executed</param> /// <param name="resultType">QueryResultType to return</param> /// <param name="conn">The SqlConnection to execute the Command on</param> /// <returns> /// System.Object cast to QueryResultType value. /// Return types are: SqlDataReader, DataSet, System.Int, System.Object /// </returns> private static object ExecuteQuery(SqlCommand queryCommand, QueryResultType resultType, SqlConnection conn) { //Make sure we don't try to open an already-open connection if (conn.State != ConnectionState.Open) { conn.Open(); } queryCommand.Connection = conn; switch (resultType) { case QueryResultType.DataReader: return queryCommand.ExecuteReader(); case QueryResultType.DataSet: { DataSet ds = new DataSet(); ds.Locale = CultureInfo.CurrentCulture; using (SqlDataAdapter da = new SqlDataAdapter()) { da.SelectCommand = queryCommand; da.Fill(ds); } return ds; } case QueryResultType.Null: return queryCommand.ExecuteNonQuery(); case QueryResultType.Scalar: return queryCommand.ExecuteScalar(); default: throw new ArgumentOutOfRangeException("resultType", "resultType is not a valid QueryResultType"); } }
public void SetResultState(QueryResultType queryResultType) { this.QueryResultType = queryResultType; }
public TableResultColumn(string name, QueryResultType type) { Name = name; Type = type; }
async Task <IEnumerable <T> > GetAndCastNextResultAsync <T>(QueryResultType type, QueryOptions options) { QueryResult r = await this.GetNextAsync(options); return(CastResultContent <T>(r, type)); }
async Task <IEnumerable <T> > GetAndCastNextResultAsync <T>(QueryResultType type, QueryOptions options) { QueryResult r = await GetNextAsync(options).ConfigureAwait(false); return(CastResultContent <T>(r, type)); }
private QueryResult(Error error, TOutput output, QueryResultType type) { _error = error; Output = output; _type = type; }
public FindAttribute() { EntityType = typeof(Object); // Default value QueryName = ""; // Default value ResultType = QueryResultType.REFERENCES; // Default value }