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
- _FtpControlStream.cs
- ConfigXmlElement.cs
- TemplateColumn.cs
- SafePointer.cs
- SpecularMaterial.cs
- GeneralTransform2DTo3DTo2D.cs
- X509CertificateTokenFactoryCredential.cs
- GridItemCollection.cs
- ExternalException.cs
- ControllableStoryboardAction.cs
- PassportAuthenticationEventArgs.cs
- MenuAdapter.cs
- IISUnsafeMethods.cs
- Pointer.cs
- AssemblyAttributesGoHere.cs
- CombinedTcpChannel.cs
- ReflectionHelper.cs
- AnnotationComponentManager.cs
- DesignTimeType.cs
- MethodBuilder.cs
- QueryableDataSourceHelper.cs
- ThumbButtonInfoCollection.cs
- TemplateColumn.cs
- SchemaImporter.cs
- SqlCommandSet.cs
- WindowsRebar.cs
- OdbcPermission.cs
- WindowsPen.cs
- UpdateCommand.cs
- TextCollapsingProperties.cs
- XPathException.cs
- milexports.cs
- ImmutableAssemblyCacheEntry.cs
- ExpressionsCollectionConverter.cs
- PropertyBuilder.cs
- AlternationConverter.cs
- DataGridViewHeaderCell.cs
- WsdlBuildProvider.cs
- BindingSourceDesigner.cs
- Int32Collection.cs
- WebPartVerbCollection.cs
- OleDbConnectionFactory.cs
- WindowsTokenRoleProvider.cs
- ListViewItemCollectionEditor.cs
- ModifierKeysValueSerializer.cs
- PointHitTestResult.cs
- SiteMapNode.cs
- CorrelationManager.cs
- SettingsPropertyIsReadOnlyException.cs
- DataBoundLiteralControl.cs
- FontFamilyValueSerializer.cs
- TextTrailingCharacterEllipsis.cs
- BindValidationContext.cs
- COMException.cs
- SqlResolver.cs
- DirtyTextRange.cs
- CmsUtils.cs
- RuntimeConfigLKG.cs
- XPathNodeList.cs
- SchemaImporterExtension.cs
- CommonDialog.cs
- SqlTypesSchemaImporter.cs
- CachedTypeface.cs
- RecommendedAsConfigurableAttribute.cs
- DecoderNLS.cs
- SubMenuStyleCollection.cs
- FormCollection.cs
- ScrollChrome.cs
- SqlDataSourceStatusEventArgs.cs
- ImmutableObjectAttribute.cs
- ObjectStateManager.cs
- StaticDataManager.cs
- XmlParser.cs
- CodeCatchClause.cs
- InfoCardTrace.cs
- RankException.cs
- RIPEMD160Managed.cs
- InstanceDescriptor.cs
- TextBlockAutomationPeer.cs
- WorkflowPrinting.cs
- RemotingException.cs
- TextBox.cs
- TraceRecord.cs
- HMACSHA384.cs
- SaveFileDialog.cs
- CodeSnippetCompileUnit.cs
- ReferencedAssemblyResolver.cs
- AspNetHostingPermission.cs
- TextBoxBase.cs
- DeliveryRequirementsAttribute.cs
- DataSpaceManager.cs
- WindowsImpersonationContext.cs
- TimeIntervalCollection.cs
- SoapAttributeAttribute.cs
- DoubleAnimationUsingKeyFrames.cs
- ReplacementText.cs
- FormParameter.cs
- UIPropertyMetadata.cs
- prefixendpointaddressmessagefilter.cs
- IndicCharClassifier.cs