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
- CodeExporter.cs
- TargetFrameworkAttribute.cs
- TextElement.cs
- UntypedNullExpression.cs
- SQLInt64Storage.cs
- HttpContext.cs
- ErrorLog.cs
- XmlBufferReader.cs
- ChildChangedEventArgs.cs
- HtmlTitle.cs
- WebPartsPersonalization.cs
- AnimatedTypeHelpers.cs
- AdapterUtil.cs
- DbDeleteCommandTree.cs
- HttpApplicationStateWrapper.cs
- IntranetCredentialPolicy.cs
- Point4D.cs
- DesignerSerializationManager.cs
- MatrixIndependentAnimationStorage.cs
- DesignerOptionService.cs
- ITextView.cs
- RequestCachePolicy.cs
- ConnectionsZone.cs
- HMACMD5.cs
- DataListItemEventArgs.cs
- ErrorEventArgs.cs
- EntityClientCacheKey.cs
- XmlSchemaSet.cs
- Assembly.cs
- FastEncoder.cs
- GroupItem.cs
- TdsParserStaticMethods.cs
- XmlSchema.cs
- ScriptControl.cs
- XmlBinaryReaderSession.cs
- StrokeCollectionDefaultValueFactory.cs
- UniformGrid.cs
- SubclassTypeValidator.cs
- SharedConnectionListener.cs
- DesignerSerializationVisibilityAttribute.cs
- AssemblyInfo.cs
- TreeViewHitTestInfo.cs
- UrlAuthFailureHandler.cs
- SupportsEventValidationAttribute.cs
- WebPartsSection.cs
- Tool.cs
- Focus.cs
- HostProtectionPermission.cs
- StatusStrip.cs
- ResourceProviderFactory.cs
- SByte.cs
- ListDictionaryInternal.cs
- PreloadedPackages.cs
- BuildProvider.cs
- LoginDesignerUtil.cs
- QueryOperator.cs
- BindingNavigatorDesigner.cs
- XsltCompileContext.cs
- SafeRightsManagementQueryHandle.cs
- BoundPropertyEntry.cs
- MailHeaderInfo.cs
- MarkerProperties.cs
- HttpResponseHeader.cs
- InputScopeConverter.cs
- FreezableOperations.cs
- ToolStripSystemRenderer.cs
- AnonymousIdentificationModule.cs
- EmptyQuery.cs
- StructuralObject.cs
- XmlKeywords.cs
- CreationContext.cs
- EntityDataSourceValidationException.cs
- CompressedStack.cs
- CodeSnippetStatement.cs
- CheckedListBox.cs
- _LazyAsyncResult.cs
- PageBuildProvider.cs
- LabelInfo.cs
- ListBox.cs
- Internal.cs
- BindValidationContext.cs
- TextReader.cs
- EntityContainerEntitySet.cs
- NameSpaceEvent.cs
- EllipseGeometry.cs
- ListViewItemMouseHoverEvent.cs
- TableAutomationPeer.cs
- ThreadExceptionEvent.cs
- ReflectionServiceProvider.cs
- SmtpLoginAuthenticationModule.cs
- SurrogateEncoder.cs
- CompiledQuery.cs
- BamlResourceSerializer.cs
- Bitmap.cs
- GeometryDrawing.cs
- ValidatedControlConverter.cs
- ScrollChrome.cs
- HyperLink.cs
- MenuBase.cs
- JournalEntry.cs