Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / Utils / ExternalCalls.cs / 1305376 / ExternalCalls.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Mapping.ViewGeneration.Structures;
using System.Data.Common;
using System.Data.Common.CommandTrees;
using System.Data.Common.CommandTrees.ExpressionBuilder;
using System.Data.Common.EntitySql;
using System.Data.Common.Utils;
using System.Data.Metadata.Edm;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
namespace System.Data.Mapping.ViewGeneration.Utils
{
// This class encapsulates "external" calls from view/UDF generation
// to other System.Data.Entity features
internal static class ExternalCalls
{
static internal bool IsReservedKeyword(string name)
{
return CqlLexer.IsReservedKeyword(name);
}
static internal DbCommandTree CompileView(
string viewDef,
StorageMappingItemCollection mappingItemCollection,
ParserOptions.CompilationMode compilationMode)
{
Debug.Assert(!String.IsNullOrEmpty(viewDef), "!String.IsNullOrEmpty(viewDef)");
Debug.Assert(mappingItemCollection != null, "mappingItemCollection != null");
Debug.Assert(mappingItemCollection.EdmItemCollection != null, "mappingItemCollection.EdmItemCollection != null");
Debug.Assert(mappingItemCollection.StoreItemCollection != null, "mappingItemCollection.StoreItemCollection != null");
MetadataWorkspace workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(mappingItemCollection.EdmItemCollection);
workspace.RegisterItemCollection(mappingItemCollection.StoreItemCollection);
workspace.RegisterItemCollection(mappingItemCollection);
Perspective perspective = new TargetPerspective(workspace);
ParserOptions parserOptions = new ParserOptions();
parserOptions.ParserCompilationMode = compilationMode;
DbCommandTree expr = CqlQuery.Compile(viewDef, perspective, parserOptions, null);
Debug.Assert(expr != null, "Compile returned empty tree?");
return expr;
}
///
/// Compiles eSQL and returns .
/// Guarantees type match of lambda variables and .
/// Passes thru all excepions coming from .
///
static internal DbLambda CompileFunctionDefinition(
string functionFullName,
string functionDefinition,
IList functionParameters,
EdmItemCollection edmItemCollection)
{
Debug.Assert(!String.IsNullOrEmpty(functionFullName), "!String.IsNullOrEmpty(functionFullName)");
Debug.Assert(!String.IsNullOrEmpty(functionDefinition), "!String.IsNullOrEmpty(functionDefinition)");
Debug.Assert(functionParameters != null, "functionParameters != null");
Debug.Assert(edmItemCollection != null, "edmItemCollection != null");
MetadataWorkspace workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(edmItemCollection);
Perspective perspective = new ModelPerspective(workspace);
// Since we compile lambda expression and generate variables from the function parameter definitions,
// the returned DbLambda will contain variable types that match function parameter types.
DbLambda functionBody = CqlQuery.CompileQueryCommandLambda(
functionDefinition,
perspective,
null /* use default parser options */,
null /* parameters */,
functionParameters.Select(pInfo => pInfo.TypeUsage.Variable(pInfo.Name)));
Debug.Assert(functionBody != null, "functionBody != null");
return functionBody;
}
static internal ItemCollection GetItemCollection(MetadataWorkspace workspace, DataSpace space)
{
return workspace.GetItemCollection(space);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Mapping.ViewGeneration.Structures;
using System.Data.Common;
using System.Data.Common.CommandTrees;
using System.Data.Common.CommandTrees.ExpressionBuilder;
using System.Data.Common.EntitySql;
using System.Data.Common.Utils;
using System.Data.Metadata.Edm;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
namespace System.Data.Mapping.ViewGeneration.Utils
{
// This class encapsulates "external" calls from view/UDF generation
// to other System.Data.Entity features
internal static class ExternalCalls
{
static internal bool IsReservedKeyword(string name)
{
return CqlLexer.IsReservedKeyword(name);
}
static internal DbCommandTree CompileView(
string viewDef,
StorageMappingItemCollection mappingItemCollection,
ParserOptions.CompilationMode compilationMode)
{
Debug.Assert(!String.IsNullOrEmpty(viewDef), "!String.IsNullOrEmpty(viewDef)");
Debug.Assert(mappingItemCollection != null, "mappingItemCollection != null");
Debug.Assert(mappingItemCollection.EdmItemCollection != null, "mappingItemCollection.EdmItemCollection != null");
Debug.Assert(mappingItemCollection.StoreItemCollection != null, "mappingItemCollection.StoreItemCollection != null");
MetadataWorkspace workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(mappingItemCollection.EdmItemCollection);
workspace.RegisterItemCollection(mappingItemCollection.StoreItemCollection);
workspace.RegisterItemCollection(mappingItemCollection);
Perspective perspective = new TargetPerspective(workspace);
ParserOptions parserOptions = new ParserOptions();
parserOptions.ParserCompilationMode = compilationMode;
DbCommandTree expr = CqlQuery.Compile(viewDef, perspective, parserOptions, null);
Debug.Assert(expr != null, "Compile returned empty tree?");
return expr;
}
///
/// Compiles eSQL and returns .
/// Guarantees type match of lambda variables and .
/// Passes thru all excepions coming from .
///
static internal DbLambda CompileFunctionDefinition(
string functionFullName,
string functionDefinition,
IList functionParameters,
EdmItemCollection edmItemCollection)
{
Debug.Assert(!String.IsNullOrEmpty(functionFullName), "!String.IsNullOrEmpty(functionFullName)");
Debug.Assert(!String.IsNullOrEmpty(functionDefinition), "!String.IsNullOrEmpty(functionDefinition)");
Debug.Assert(functionParameters != null, "functionParameters != null");
Debug.Assert(edmItemCollection != null, "edmItemCollection != null");
MetadataWorkspace workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(edmItemCollection);
Perspective perspective = new ModelPerspective(workspace);
// Since we compile lambda expression and generate variables from the function parameter definitions,
// the returned DbLambda will contain variable types that match function parameter types.
DbLambda functionBody = CqlQuery.CompileQueryCommandLambda(
functionDefinition,
perspective,
null /* use default parser options */,
null /* parameters */,
functionParameters.Select(pInfo => pInfo.TypeUsage.Variable(pInfo.Name)));
Debug.Assert(functionBody != null, "functionBody != null");
return functionBody;
}
static internal ItemCollection GetItemCollection(MetadataWorkspace workspace, DataSpace space)
{
return workspace.GetItemCollection(space);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SourceFileBuildProvider.cs
- BitmapEffectGeneralTransform.cs
- OutputCacheSettings.cs
- GenericUriParser.cs
- mediaclock.cs
- CancelEventArgs.cs
- TextEndOfLine.cs
- NonVisualControlAttribute.cs
- ListViewGroup.cs
- ConstraintConverter.cs
- StaticDataManager.cs
- ScriptReference.cs
- Interlocked.cs
- FillBehavior.cs
- CuspData.cs
- AddInServer.cs
- ReliabilityContractAttribute.cs
- RelAssertionDirectKeyIdentifierClause.cs
- AttachedProperty.cs
- XhtmlBasicTextBoxAdapter.cs
- EndpointAddressAugust2004.cs
- AtomMaterializer.cs
- BaseProcessProtocolHandler.cs
- PaintValueEventArgs.cs
- FolderBrowserDialog.cs
- TargetFrameworkUtil.cs
- SubclassTypeValidator.cs
- UpdateManifestForBrowserApplication.cs
- PartialCachingControl.cs
- ReadOnlyDataSource.cs
- System.Data_BID.cs
- BaseAsyncResult.cs
- sqlstateclientmanager.cs
- ConnectionInterfaceCollection.cs
- DbConnectionHelper.cs
- HtmlTableRowCollection.cs
- DetailsViewModeEventArgs.cs
- FrameworkElement.cs
- ColorAnimationUsingKeyFrames.cs
- FormatterServicesNoSerializableCheck.cs
- HttpStreamXmlDictionaryWriter.cs
- EventLogPermissionEntryCollection.cs
- GlyphCache.cs
- TransformerConfigurationWizardBase.cs
- InputProcessorProfilesLoader.cs
- ManagedFilter.cs
- ControllableStoryboardAction.cs
- WebServiceData.cs
- XslException.cs
- SoapInteropTypes.cs
- ScrollPattern.cs
- SessionMode.cs
- WebPartVerbCollection.cs
- CodeLabeledStatement.cs
- LabelEditEvent.cs
- NamedPipeHostedTransportConfiguration.cs
- BamlLocalizationDictionary.cs
- Latin1Encoding.cs
- CryptoProvider.cs
- Currency.cs
- RangeBase.cs
- ContractUtils.cs
- StringUtil.cs
- QueryOutputWriter.cs
- TreeNodeClickEventArgs.cs
- CodeAttachEventStatement.cs
- HtmlControlPersistable.cs
- TemplateLookupAction.cs
- DataColumnCollection.cs
- DataTableMapping.cs
- TypeLoadException.cs
- ContainsRowNumberChecker.cs
- DragCompletedEventArgs.cs
- BuildManager.cs
- WmlControlAdapter.cs
- DataGridViewSortCompareEventArgs.cs
- FixedSOMTableRow.cs
- CaseInsensitiveComparer.cs
- SingleResultAttribute.cs
- TrackingProfile.cs
- DataRow.cs
- SecurityPermission.cs
- HttpMethodConstraint.cs
- MexBindingBindingCollectionElement.cs
- TextParagraphCache.cs
- StyleBamlTreeBuilder.cs
- Message.cs
- LiteralLink.cs
- RepeaterCommandEventArgs.cs
- InfoCardTraceRecord.cs
- SimpleColumnProvider.cs
- CodeTryCatchFinallyStatement.cs
- ArrowControl.xaml.cs
- StrokeCollection.cs
- UnsafeNativeMethods.cs
- WebConfigurationHost.cs
- processwaithandle.cs
- TextCompositionManager.cs
- SqlFunctionAttribute.cs
- ExtensionSurface.cs