Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlParameterizer.cs / 1305376 / SqlParameterizer.cs
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.Linq.Mapping; using System.Data.Linq.Provider; using System.Linq.Expressions; using System.Diagnostics.CodeAnalysis; namespace System.Data.Linq.SqlClient { internal enum SqlParameterType { Value, UserArgument, PreviousResult } internal class SqlParameterInfo { SqlParameter parameter; object value; Delegate accessor; internal SqlParameterInfo(SqlParameter parameter, Delegate accessor) { this.parameter = parameter; this.accessor = accessor; } internal SqlParameterInfo(SqlParameter parameter, object value) { this.parameter = parameter; this.value = value; } internal SqlParameterInfo(SqlParameter parameter) { this.parameter = parameter; } internal SqlParameterType Type { get { if (this.accessor != null) { return SqlParameterType.UserArgument; } else if (this.parameter.Name == "@ROWCOUNT") { return SqlParameterType.PreviousResult; } else { return SqlParameterType.Value; } } } internal SqlParameter Parameter { get { return this.parameter; } } internal Delegate Accessor { get { return this.accessor; } } internal object Value { get { return this.value; } } } internal class SqlParameterizer { TypeSystemProvider typeProvider; SqlNodeAnnotations annotations; int index; internal SqlParameterizer(TypeSystemProvider typeProvider, SqlNodeAnnotations annotations) { this.typeProvider = typeProvider; this.annotations = annotations; } internal ReadOnlyCollectionParameterize(SqlNode node) { return this.ParameterizeInternal(node).AsReadOnly(); } private List ParameterizeInternal(SqlNode node) { Visitor v = new Visitor(this); v.Visit(node); return new List (v.currentParams); } internal ReadOnlyCollection > ParameterizeBlock(SqlBlock block) { SqlParameterInfo rowStatus = new SqlParameterInfo( new SqlParameter(typeof(int), typeProvider.From(typeof(int)), "@ROWCOUNT", block.SourceExpression) ); List > list = new List >(); for (int i = 0, n = block.Statements.Count; i < n; i++) { SqlNode statement = block.Statements[i]; List parameters = this.ParameterizeInternal(statement); if (i > 0) { parameters.Add(rowStatus); } list.Add(parameters.AsReadOnly()); } return list.AsReadOnly(); } internal virtual string CreateParameterName() { return "@p" + this.index++; } class Visitor : SqlVisitor { private SqlParameterizer parameterizer; internal Dictionary
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RegistrationServices.cs
- MetadataProperty.cs
- HtmlDocument.cs
- DBCommand.cs
- _AutoWebProxyScriptHelper.cs
- StyleBamlRecordReader.cs
- XmlAttribute.cs
- DateTimeParse.cs
- BooleanToVisibilityConverter.cs
- VideoDrawing.cs
- SkipQueryOptionExpression.cs
- JpegBitmapDecoder.cs
- UrlAuthFailedErrorFormatter.cs
- ArrayItemReference.cs
- DataSpaceManager.cs
- QuerySafeNavigator.cs
- BadImageFormatException.cs
- Preprocessor.cs
- UdpConstants.cs
- DoubleCollectionConverter.cs
- InteropAutomationProvider.cs
- ExceptionNotification.cs
- PropertyKey.cs
- SplitterPanel.cs
- ColumnResizeAdorner.cs
- DataAdapter.cs
- SupportingTokenProviderSpecification.cs
- QilInvokeLateBound.cs
- localization.cs
- Popup.cs
- SoapInteropTypes.cs
- RevocationPoint.cs
- DefaultHttpHandler.cs
- _HeaderInfoTable.cs
- PasswordBox.cs
- WindowsButton.cs
- SubclassTypeValidatorAttribute.cs
- CheckBox.cs
- PropertyGeneratedEventArgs.cs
- CodeDomSerializer.cs
- TimeSpanParse.cs
- WebPartEditorApplyVerb.cs
- MergeLocalizationDirectives.cs
- DataDocumentXPathNavigator.cs
- ObfuscationAttribute.cs
- StylusPointCollection.cs
- XmlReturnWriter.cs
- DecimalStorage.cs
- XmlElementCollection.cs
- TypedDatasetGenerator.cs
- InplaceBitmapMetadataWriter.cs
- WebHttpBindingElement.cs
- Main.cs
- CompModSwitches.cs
- AppDomainFactory.cs
- HtmlInputButton.cs
- Empty.cs
- DataSourceHelper.cs
- CasesDictionary.cs
- SQlBooleanStorage.cs
- CanonicalFontFamilyReference.cs
- HotSpot.cs
- WindowsListViewGroupHelper.cs
- DoubleCollection.cs
- WorkflowDesigner.cs
- ReadOnlyCollectionBase.cs
- ExtendLockAsyncResult.cs
- CustomCredentialPolicy.cs
- FileSystemWatcher.cs
- ParameterReplacerVisitor.cs
- SessionSwitchEventArgs.cs
- coordinatorfactory.cs
- SecurityState.cs
- CommonProperties.cs
- SuppressMergeCheckAttribute.cs
- PageContentAsyncResult.cs
- X509CertificateCollection.cs
- CommonGetThemePartSize.cs
- ScrollBar.cs
- ServiceCredentials.cs
- IriParsingElement.cs
- MetaColumn.cs
- DynamicRendererThreadManager.cs
- DataControlReference.cs
- BaseAsyncResult.cs
- EventProviderWriter.cs
- SymbolPair.cs
- CalendarDateRange.cs
- XmlValidatingReader.cs
- FormParameter.cs
- StrokeNode.cs
- TemplateComponentConnector.cs
- UnconditionalPolicy.cs
- EntityDataReader.cs
- EntityDataSourceConfigureObjectContext.cs
- SerializationInfo.cs
- Fonts.cs
- IPAddressCollection.cs
- HttpHeaderCollection.cs
- UiaCoreProviderApi.cs