Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWebControls / System / Data / WebControls / EntityDataSourceView.cs / 1599186 / EntityDataSourceView.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.DynamicData;
using System.Runtime.CompilerServices;
namespace System.Web.UI.WebControls
{
public sealed class EntityDataSourceView : DataSourceView, IStateManager
{
private EntityDataSource _owner;
private ObjectContext _ctx = null;
private ReadOnlyMetadataCollection _keyMembers = null;
private EntityDataSourceWrapperCollection _wrapperCollection = null;
private static readonly object EventContextCreated = new object();
private static readonly object EventContextCreating = new object();
private static readonly object EventContextDisposing = new object();
private static readonly object EventDeleted = new object();
private static readonly object EventDeleting = new object();
private static readonly object EventInserted = new object();
private static readonly object EventInserting = new object();
private static readonly object EventSelected = new object();
private static readonly object EventSelecting = new object();
private static readonly object EventUpdated = new object();
private static readonly object EventUpdating = new object();
private static readonly object EventException = new object();
private static readonly object EventQueryCreated = new object();
// values saved in ViewState
private bool _disableUpdates = false;
private bool _tracking = false;
private Dictionary _originalProperties;
#region Constructor
internal EntityDataSourceView(EntityDataSource owner, string viewName)
: base(owner, viewName)
{
_owner = owner;
}
#endregion Constructor
#region ExecuteSelect
private static readonly MethodInfo _executeSelectMethod = typeof(EntityDataSourceView).GetMethod("ExecuteSelectTyped", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly MethodInfo _continueSelectMethod = typeof(EntityDataSourceView).GetMethod("ContinueSelectTyped", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly Type[] queryBuilderCreatorArgTypes = { typeof(DataSourceSelectArguments), typeof(string), typeof(ObjectParameter[]),
typeof(string), typeof(ObjectParameter[]), typeof(string),
typeof(string), typeof(string), typeof(ObjectParameter[]),
typeof(OrderByBuilder), typeof(string) };
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
{
_wrapperCollection = null;
AddSupportedCapabilities(arguments);
arguments.RaiseUnsupportedCapabilitiesError(this);
ConstructContext();
var selectArgs = new EntityDataSourceSelectingEventArgs(_owner, arguments);
OnSelecting(selectArgs);
if (selectArgs.Cancel)
{
return null;
}
_disableUpdates = _owner.ValidateUpdatableConditions();
if (_owner.ValidateWrappable())
{
_wrapperCollection = new EntityDataSourceWrapperCollection(Context, EntitySet, CSpaceFilteredEntityType);
}
if (!string.IsNullOrEmpty(_owner.Select))
{
return ExecuteSelectTyped(arguments, EntityDataSourceRecordQueryBuilder.Create);
}
else if (!string.IsNullOrEmpty(_owner.CommandText))
{
return ExecuteSelectTyped