protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError(this); XmlNode xmlDocument = this._owner.GetXmlDocument(); XmlNodeList nodes = null; if (this._owner.XPath.Length != 0) { nodes = xmlDocument.SelectNodes(this._owner.XPath); } else { nodes = xmlDocument.SelectNodes("/node()/node()"); } return(new XmlDataSourceNodeDescriptorEnumeration(nodes)); }
private void AddSupportedCapabilities(DataSourceSelectArguments arguments) { if (CanSort) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort); } if (CanRetrieveTotalRowCount) { arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); } if (CanPage) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Page); } arguments.RaiseUnsupportedCapabilitiesError(this); }
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { NBearDataSourceSelectingEventArgs selectingArgs = new NBearDataSourceSelectingEventArgs(arguments); owner.OnSelecting(selectingArgs); arguments = selectingArgs.SelectArguments == null ? DataSourceSelectArguments.Empty : selectingArgs.SelectArguments; arguments.RaiseUnsupportedCapabilitiesError(this); Gateway gateway = owner.Gateway; Type type = Util.GetType(this.owner.TypeName); string sort = owner.DefaultOrderByExpression; if (!string.IsNullOrEmpty(arguments.SortExpression)) { string[] parts = arguments.SortExpression.Split(new char[] { ' ' }, 2); string field = "{" + parts[0] + "}"; sort = field + (parts.Length >= 2 ? " " + parts[1] : " ASC"); } int page = (arguments.MaximumRows > 0 ? (arguments.StartRowIndex / arguments.MaximumRows) + 1 : 1); WhereClip where = string.IsNullOrEmpty(owner.FilterExpression) ? WhereClip.All : new WhereClip(owner.FilterExpression); OrderByClip orderBy = string.IsNullOrEmpty(sort) ? OrderByClip.Default : new OrderByClip(sort); Array list; if (arguments.MaximumRows > 0) { object pageSelector = typeof(Gateway).GetMethod("GetPageSelector").MakeGenericMethod(type).Invoke(gateway, new object[] { where, orderBy, arguments.MaximumRows }); list = (Array)typeof(PageSelector <>).MakeGenericType(type).GetMethod("FindPage").Invoke(pageSelector, new object[] { page }); } else { list = (Array)GetGatewayMethodInfo("EntityType[] FindArray[EntityType](NBear.Common.WhereClip, NBear.Common.OrderByClip)").MakeGenericMethod(type).Invoke(gateway, new object[] { where, orderBy }); } if (arguments.RetrieveTotalRowCount) { arguments.TotalRowCount = (int)GetGatewayMethodInfo("Int32 Count[EntityType](NBear.Common.WhereClip)").MakeGenericMethod(type).Invoke(gateway, new object[] { where }); } NBearDataSourceSelectedEventArgs selectedArgs = new NBearDataSourceSelectedEventArgs(arguments, list); owner.OnSelected(selectedArgs); return(selectedArgs.ResultEntities); }
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError(this); DataTable dt = _owner.GetDataTable(); if (dt == null) { return(new DataTable().DefaultView); } _dataView = new DataView(dt); PerformFiltering(); PerformSorting(arguments.SortExpression); return(_dataView); }
/// <devdoc> /// Returns all the rows of the datasource. /// </devdoc> protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError(this); XmlNode root = _owner.GetXmlDocument(); XmlNodeList nodes = null; if (_owner.XPath.Length != 0) { // If an XPath is specified on the control, use it nodes = root.SelectNodes(_owner.XPath); } else { // Otherwise, get all the children of the root nodes = root.SelectNodes("/node()/node()"); } return(new XmlDataSourceNodeDescriptorEnumeration(nodes)); }
protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError(this); return(this._collection); }
protected override IAsyncResult BeginExecuteSelect( DataSourceSelectArguments arguments, AsyncCallback asyncCallback, object asyncState) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Begin"); if (CanSort) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort); } if (CanPage) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Page); } if (CanRetrieveTotalRowCount) { arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); } string fetchXml; QueryByAttribute query; InitializeParameters(out fetchXml, out query); // raise pre-event CrmDataSourceSelectingEventArgs selectingArgs = new CrmDataSourceSelectingEventArgs( Owner, arguments, fetchXml, query); OnSelecting(selectingArgs); IEnumerable selectResult = null; if (selectingArgs.Cancel) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Cancel"); return(new SynchronousAsyncSelectResult(selectResult, asyncCallback, asyncState)); } // merge event results arguments.RaiseUnsupportedCapabilitiesError(this); fetchXml = selectingArgs.FetchXml; if (CancelSelectOnNullParameter && string.IsNullOrEmpty(fetchXml) && query == null) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "CancelSelectOnNullParameter"); return(new SynchronousAsyncSelectResult(selectResult, asyncCallback, asyncState)); } try { _client = OrganizationServiceContextFactory.Create(Owner.CrmDataContextName); if (!string.IsNullOrEmpty(fetchXml)) { var fetch = ToFetch(arguments, fetchXml); ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End"); return(ExecuteSelect(_client, null, fetch, asyncCallback, asyncState)); } if (query != null) { ADXTrace.Instance.TraceInfo(TraceCategory.Application, "QueryByAttribute"); // the SortExpression has high priority, apply it to the query AppendSortExpressionToQuery(arguments.SortExpression, order => query.Orders.Add(order)); ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End"); return(ExecuteSelect(_client, query, null, asyncCallback, asyncState)); } } catch (System.Web.Services.Protocols.SoapException ex) { ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("{0}\n\n{1}", ex.Detail.InnerXml, ex.ToString())); } catch (Exception e) { ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("Exception: {0}", e.ToString())); _client = null; return(new SynchronousAsyncSelectResult(e, asyncCallback, asyncState)); } ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End"); return(new SynchronousAsyncSelectResult(selectResult, asyncCallback, asyncState)); }
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments args) { args.AddSupportedCapabilities(DataSourceCapabilities.Page); args.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); args.RaiseUnsupportedCapabilitiesError(this); var parameters = Owner.SelectParameters.GetValues(HttpContext.Current, Owner); var filter = GetFilter(args, parameters); var logicalNames = GetLogicalNames(args, parameters); var pageSize = GetPageSize(args, parameters); var pageNumber = GetPageNumber(args, parameters, pageSize); var queryText = GetQueryText(args, parameters); ContextLanguageInfo contextLanguage; var multiLanguageEnabled = TryGetLanguageCode(out contextLanguage); if (string.IsNullOrWhiteSpace(queryText) && string.IsNullOrWhiteSpace(filter)) { args.TotalRowCount = 0; return(new CrmEntitySearchResultPage(new List <ICrmEntitySearchResult>(), 0, pageNumber, pageSize)); } var provider = SearchManager.GetProvider(Owner.SearchProvider); var query = new CrmEntityQuery(queryText, pageNumber, pageSize, logicalNames, contextLanguage.ContextLanguage, multiLanguageEnabled, filter); var selectingArgs = new SearchDataSourceSelectingEventArgs(provider, query); Owner.OnSelecting(selectingArgs); if (selectingArgs.Cancel) { args.TotalRowCount = 0; return(new CrmEntitySearchResultPage(new List <ICrmEntitySearchResult>(), 0, pageNumber, pageSize)); } try { using (var searcher = provider.GetIndexSearcher()) { var results = searcher.Search(query); args.TotalRowCount = results.ApproximateTotalHits; Owner.OnSelected(new SearchDataSourceStatusEventArgs(provider, query, results)); return(results); } } catch (Exception e) { ADXTrace.Instance.TraceError(TraceCategory.Application, e.ToString()); var selectedArgs = new SearchDataSourceStatusEventArgs(provider, query, new CrmEntitySearchResultPage(new List <ICrmEntitySearchResult>(), 0, pageNumber, pageSize)) { Exception = e }; Owner.OnSelected(selectedArgs); if (!selectedArgs.ExceptionHandled) { throw; } args.TotalRowCount = 0; return(new CrmEntitySearchResultPage(new List <ICrmEntitySearchResult>(), 0, pageNumber, pageSize)); } }
public void RaiseUnsupportedCapabilitiesError() { PockerDataSourceView view = new PockerDataSourceView(); DataSourceSelectArguments arg = new DataSourceSelectArguments(); arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsFalse(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.StartRowIndex = 10; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.Page, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.MaximumRows = 5; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.Page, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.SortExpression = "Sort"; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.Sort, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.RetrieveTotalRowCount = true; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.RetrieveTotalRowCount, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.AddSupportedCapabilities(DataSourceCapabilities.Page | DataSourceCapabilities.Sort | DataSourceCapabilities.RetrieveTotalRowCount); arg.SortExpression = "Sort"; arg.StartRowIndex = 10; arg.MaximumRows = 5; arg.RetrieveTotalRowCount = true; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsFalse(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.SortExpression = "Sort"; arg.StartRowIndex = 10; arg.MaximumRows = 5; arg.RetrieveTotalRowCount = true; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.RetrieveTotalRowCount, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); view = new PockerDataSourceView(); arg = new DataSourceSelectArguments(); arg.SortExpression = "Sort"; arg.StartRowIndex = 10; arg.MaximumRows = 5; arg.RaiseUnsupportedCapabilitiesError(view); Assert.IsTrue(view.RaiseUnsupportedCapabilityErrorCalled, "RaiseUnsupportedCapabilitiesError"); Assert.AreEqual(DataSourceCapabilities.Page, view.DataSourceCapabilities, "RaiseUnsupportedCapabilitiesError"); }
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError(this); return(GetMonitorData()); }
protected internal override IEnumerable ExecuteSelect (DataSourceSelectArguments arguments) { arguments.RaiseUnsupportedCapabilitiesError (this); IOrderedDictionary paramValues = MergeParameterValues (SelectParameters, null, null); ObjectDataSourceSelectingEventArgs args = new ObjectDataSourceSelectingEventArgs (paramValues, arguments, false); object result = null; if (owner.EnableCaching) result = owner.Cache.GetCachedObject (SelectMethod, SelectParameters); if (result == null) { OnSelecting (args); if (args.Cancel) return new ArrayList (); if (CanPage) { if (StartRowIndexParameterName.Length == 0) throw new InvalidOperationException ("Paging is enabled, but the StartRowIndexParameterName property is not set."); if (MaximumRowsParameterName.Length == 0) throw new InvalidOperationException ("Paging is enabled, but the MaximumRowsParameterName property is not set."); paramValues [StartRowIndexParameterName] = arguments.StartRowIndex; paramValues [MaximumRowsParameterName] = arguments.MaximumRows; } if (SortParameterName.Length > 0) paramValues [SortParameterName] = arguments.SortExpression; result = InvokeSelect (SelectMethod, paramValues); if (CanRetrieveTotalRowCount && arguments.RetrieveTotalRowCount) arguments.TotalRowCount = QueryTotalRowCount (MergeParameterValues (SelectParameters, null, null), arguments); if (owner.EnableCaching) owner.Cache.SetCachedObject (SelectMethod, SelectParameters, result); } if (FilterExpression.Length > 0 && !(result is DataGrid || result is DataView || result is DataTable)) throw new NotSupportedException ("The FilterExpression property was set and the Select method does not return a DataSet, DataTable, or DataView."); if (owner.EnableCaching && result is IDataReader) throw new NotSupportedException ("Data source does not support caching objects that implement IDataReader"); if (result is DataSet) { DataSet dset = (DataSet) result; if (dset.Tables.Count == 0) throw new InvalidOperationException ("The select method returnet a DataSet which doesn't contain any table."); result = dset.Tables [0]; } if (result is DataTable) { DataView dview = new DataView ((DataTable)result); if (arguments.SortExpression != null && arguments.SortExpression.Length > 0) { dview.Sort = arguments.SortExpression; } if (FilterExpression.Length > 0) { IOrderedDictionary fparams = FilterParameters.GetValues (context, owner); ObjectDataSourceFilteringEventArgs fargs = new ObjectDataSourceFilteringEventArgs (fparams); OnFiltering (fargs); if (!fargs.Cancel) { object[] formatValues = new object [fparams.Count]; for (int n=0; n<formatValues.Length; n++) { formatValues [n] = fparams [n]; if (formatValues [n] == null) return dview; } dview.RowFilter = string.Format (FilterExpression, formatValues); } } return dview; } if (result is IEnumerable) return (IEnumerable) result; else return new object[] {result}; }
protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { SqlCacheDependency dependency; if (this.SelectCommand.Length == 0) { return(null); } DbConnection connection = this._owner.CreateConnection(this._owner.ConnectionString); if (connection == null) { throw new InvalidOperationException(System.Web.SR.GetString("SqlDataSourceView_CouldNotCreateConnection", new object[] { this._owner.ID })); } DataSourceCache cache = this._owner.Cache; bool flag = (cache != null) && cache.Enabled; string sortExpression = arguments.SortExpression; if (this.CanPage) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Page); } if (this.CanSort) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort); } if (this.CanRetrieveTotalRowCount) { arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); } if (flag) { if (this._owner.DataSourceMode != SqlDataSourceMode.DataSet) { throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_CacheNotSupported", new object[] { this._owner.ID })); } arguments.RaiseUnsupportedCapabilitiesError(this); DataSet set = this._owner.LoadDataFromCache(0, -1) as DataSet; if (set != null) { IOrderedDictionary parameterValues = this.FilterParameters.GetValues(this._context, this._owner); if (this.FilterExpression.Length > 0) { SqlDataSourceFilteringEventArgs args = new SqlDataSourceFilteringEventArgs(parameterValues); this.OnFiltering(args); if (args.Cancel) { return(null); } } return(FilteredDataSetHelper.CreateFilteredDataView(set.Tables[0], sortExpression, this.FilterExpression, parameterValues)); } } DbCommand command = this._owner.CreateCommand(this.SelectCommand, connection); this.InitializeParameters(command, this.SelectParameters, null); command.CommandType = GetCommandType(this.SelectCommandType); SqlDataSourceSelectingEventArgs e = new SqlDataSourceSelectingEventArgs(command, arguments); this.OnSelecting(e); if (e.Cancel) { return(null); } string sortParameterName = this.SortParameterName; if (sortParameterName.Length > 0) { if (command.CommandType != CommandType.StoredProcedure) { throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_SortParameterRequiresStoredProcedure", new object[] { this._owner.ID })); } command.Parameters.Add(this._owner.CreateParameter(this.ParameterPrefix + sortParameterName, sortExpression)); arguments.SortExpression = string.Empty; } arguments.RaiseUnsupportedCapabilitiesError(this); sortExpression = arguments.SortExpression; if (this.CancelSelectOnNullParameter) { int count = command.Parameters.Count; for (int i = 0; i < count; i++) { DbParameter parameter = command.Parameters[i]; if (((parameter != null) && (parameter.Value == null)) && ((parameter.Direction == ParameterDirection.Input) || (parameter.Direction == ParameterDirection.InputOutput))) { return(null); } } } this.ReplaceNullValues(command); IEnumerable enumerable = null; switch (this._owner.DataSourceMode) { case SqlDataSourceMode.DataReader: { if (this.FilterExpression.Length > 0) { throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_FilterNotSupported", new object[] { this._owner.ID })); } if (sortExpression.Length > 0) { throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_SortNotSupported", new object[] { this._owner.ID })); } bool flag4 = false; try { if (connection.State != ConnectionState.Open) { connection.Open(); } enumerable = command.ExecuteReader(CommandBehavior.CloseConnection); flag4 = true; SqlDataSourceStatusEventArgs args6 = new SqlDataSourceStatusEventArgs(command, 0, null); this.OnSelected(args6); } catch (Exception exception2) { bool flag5; if (!flag4) { SqlDataSourceStatusEventArgs args7 = new SqlDataSourceStatusEventArgs(command, 0, exception2); this.OnSelected(args7); if (!args7.ExceptionHandled) { throw; } return(enumerable); } exception2 = this.BuildCustomException(exception2, DataSourceOperation.Select, command, out flag5); if (flag5) { throw exception2; } throw; } return(enumerable); } case SqlDataSourceMode.DataSet: dependency = null; if (flag && (cache is SqlDataSourceCache)) { SqlDataSourceCache cache2 = (SqlDataSourceCache)cache; if (string.Equals(cache2.SqlCacheDependency, "CommandNotification", StringComparison.OrdinalIgnoreCase)) { if (!(command is SqlCommand)) { throw new InvalidOperationException(System.Web.SR.GetString("SqlDataSourceView_CommandNotificationNotSupported", new object[] { this._owner.ID })); } dependency = new SqlCacheDependency((SqlCommand)command); break; } } break; default: return(enumerable); } DbDataAdapter adapter = this._owner.CreateDataAdapter(command); DataSet dataSet = new DataSet(); int affectedRows = 0; bool flag2 = false; try { affectedRows = adapter.Fill(dataSet, base.Name); flag2 = true; SqlDataSourceStatusEventArgs args3 = new SqlDataSourceStatusEventArgs(command, affectedRows, null); this.OnSelected(args3); } catch (Exception exception) { if (flag2) { bool flag3; exception = this.BuildCustomException(exception, DataSourceOperation.Select, command, out flag3); if (flag3) { throw exception; } throw; } SqlDataSourceStatusEventArgs args4 = new SqlDataSourceStatusEventArgs(command, affectedRows, exception); this.OnSelected(args4); if (!args4.ExceptionHandled) { throw; } } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } DataTable table = (dataSet.Tables.Count > 0) ? dataSet.Tables[0] : null; if (flag && (table != null)) { this._owner.SaveDataToCache(0, -1, dataSet, dependency); } if (table == null) { return(enumerable); } IOrderedDictionary values = this.FilterParameters.GetValues(this._context, this._owner); if (this.FilterExpression.Length > 0) { SqlDataSourceFilteringEventArgs args5 = new SqlDataSourceFilteringEventArgs(values); this.OnFiltering(args5); if (args5.Cancel) { return(null); } } return(FilteredDataSetHelper.CreateFilteredDataView(table, sortExpression, this.FilterExpression, values)); }
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "Begin"); if (CanSort) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort); } if (CanPage) { arguments.AddSupportedCapabilities(DataSourceCapabilities.Page); } if (CanRetrieveTotalRowCount) { arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); } // merge SelectParameters IOrderedDictionary parameters = SelectParameters.GetValues(Context, Owner); string sortExpression = GetNonNullOrEmpty( arguments.SortExpression, parameters[_sortExpressionParameterName] as string, SortExpression); string entityName = GetNonNullOrEmpty( parameters[_entityNameParameterName] as string, EntityName); string attributeName = GetNonNullOrEmpty( parameters[_attributeNameParameterName] as string, AttributeName); var metadataFlags = MetadataFlags; if (parameters.Contains(_metadataFlagsParameterName)) { metadataFlags = (parameters[_metadataFlagsParameterName] as string).ToEnum <EntityFilters>(); } var entityFlags = EntityFlags; if (parameters.Contains(_entityFlagsParameterName)) { entityFlags = (parameters[_entityFlagsParameterName] as string).ToEnum <EntityFilters>(); } // raise pre-event CrmMetadataDataSourceSelectingEventArgs selectingArgs = new CrmMetadataDataSourceSelectingEventArgs( Owner, arguments, entityName, attributeName, metadataFlags, entityFlags, sortExpression); OnSelecting(selectingArgs); if (selectingArgs.Cancel) { Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "Cancel"); return(null); } // merge event results arguments.RaiseUnsupportedCapabilitiesError(this); sortExpression = selectingArgs.SortExpression; entityName = selectingArgs.EntityName; attributeName = selectingArgs.AttributeName; metadataFlags = selectingArgs.MetadataFlags; entityFlags = selectingArgs.EntityFlags; if (CancelSelectOnNullParameter && string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(attributeName)) { Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "CancelSelectOnNullParameter"); return(null); } IEnumerable result = null; int rowsAffected = 0; try { if (Owner.CacheParameters.Enabled) { var cacheKey = GetCacheKey(metadataFlags, entityFlags, entityName, attributeName, sortExpression); result = ObjectCacheManager.Get(cacheKey, cache => { var metadata = ExecuteSelect(entityName, attributeName, sortExpression, entityFlags, metadataFlags, out rowsAffected); return(metadata); }, (cache, metadata) => { if (metadata != null) { var dependencies = GetCacheDependencies(metadata); cache.Insert(cacheKey, metadata, dependencies); } }); } else { result = ExecuteSelect(entityName, attributeName, sortExpression, entityFlags, metadataFlags, out rowsAffected); } } catch (System.Web.Services.Protocols.SoapException ex) { Tracing.FrameworkError("CrmMetadataDataSourceView", "ExecuteSelect", "{0}\n\n{1}", ex.Detail.InnerXml, ex); } catch (Exception e) { Tracing.FrameworkError("CrmMetadataDataSourceView", "ExecuteSelect", "Exception: {0}", e); // raise post-event with exception CrmMetadataDataSourceStatusEventArgs selectedExceptionArgs = new CrmMetadataDataSourceStatusEventArgs(0, e); OnSelected(selectedExceptionArgs); if (!selectedExceptionArgs.ExceptionHandled) { throw; } return(result); } // raise post-event CrmMetadataDataSourceStatusEventArgs selectedArgs = new CrmMetadataDataSourceStatusEventArgs(rowsAffected, null); OnSelected(selectedArgs); Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "End"); return(result); }