Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / WebControls / Expressions / PropertyExpression.cs / 1305376 / PropertyExpression.cs
#if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls.Expressions { using System.Web; using System.Web.UI.WebControls; #else namespace System.Web.UI.WebControls.Expressions { #endif using System; using System.Collections.Generic; using System.Security.Permissions; using System.Web.UI; using System.Linq.Expressions; using System.Linq; public class PropertyExpression : ParameterDataSourceExpression { public override IQueryable GetQueryable(IQueryable source) { if (source == null) { return null; } IDictionaryvalues = GetValues(); List equalsExpressions = new List (); ParameterExpression parameterExpression = Expression.Parameter(source.ElementType, String.Empty); foreach (KeyValuePair pair in values) { if (!String.IsNullOrEmpty(pair.Key)) { // Create the property expression Expression property = ExpressionHelper.CreatePropertyExpression(parameterExpression, pair.Key); // Get the value object value = ExpressionHelper.BuildObjectValue(pair.Value, property.Type); // Create Property == Value and '&&' the expressions together if (value != null) { Expression valueExpression = Expression.Constant(value, property.Type); Expression equalsExpression = Expression.Equal(property, valueExpression); equalsExpressions.Add(equalsExpression); } } } if (equalsExpressions.Any()) { Expression body = ExpressionHelper.And(equalsExpressions); return ExpressionHelper.Where(source, Expression.Lambda(body, parameterExpression)); } return source; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls.Expressions { using System.Web; using System.Web.UI.WebControls; #else namespace System.Web.UI.WebControls.Expressions { #endif using System; using System.Collections.Generic; using System.Security.Permissions; using System.Web.UI; using System.Linq.Expressions; using System.Linq; public class PropertyExpression : ParameterDataSourceExpression { public override IQueryable GetQueryable(IQueryable source) { if (source == null) { return null; } IDictionary values = GetValues(); List equalsExpressions = new List (); ParameterExpression parameterExpression = Expression.Parameter(source.ElementType, String.Empty); foreach (KeyValuePair pair in values) { if (!String.IsNullOrEmpty(pair.Key)) { // Create the property expression Expression property = ExpressionHelper.CreatePropertyExpression(parameterExpression, pair.Key); // Get the value object value = ExpressionHelper.BuildObjectValue(pair.Value, property.Type); // Create Property == Value and '&&' the expressions together if (value != null) { Expression valueExpression = Expression.Constant(value, property.Type); Expression equalsExpression = Expression.Equal(property, valueExpression); equalsExpressions.Add(equalsExpression); } } } if (equalsExpressions.Any()) { Expression body = ExpressionHelper.And(equalsExpressions); return ExpressionHelper.Where(source, Expression.Lambda(body, parameterExpression)); } return source; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MessageSecurityOverHttp.cs
- SynchronousChannelMergeEnumerator.cs
- PeerEndPoint.cs
- ToolStripGrip.cs
- ObjectConverter.cs
- BitmapDownload.cs
- BaseUriHelper.cs
- DebugView.cs
- CalendarDay.cs
- FirstMatchCodeGroup.cs
- MetaColumn.cs
- TextRange.cs
- XPathDocumentIterator.cs
- ColorConverter.cs
- FramingDecoders.cs
- X509Certificate2Collection.cs
- RangeBaseAutomationPeer.cs
- DataControlImageButton.cs
- categoryentry.cs
- DelayDesigner.cs
- TableAdapterManagerMethodGenerator.cs
- ProgressiveCrcCalculatingStream.cs
- CircleEase.cs
- ToolStripPanelRow.cs
- StickyNote.cs
- TextBox.cs
- WeakReference.cs
- RegexMatchCollection.cs
- DefaultTraceListener.cs
- ConfigurationSection.cs
- DBPropSet.cs
- MarkupProperty.cs
- Byte.cs
- URI.cs
- XslException.cs
- Opcode.cs
- GlyphTypeface.cs
- DockAndAnchorLayout.cs
- EastAsianLunisolarCalendar.cs
- PeerResolverBindingElement.cs
- ImpersonateTokenRef.cs
- SchemaNotation.cs
- Vector3D.cs
- GetWinFXPath.cs
- TransformedBitmap.cs
- DynamicMethod.cs
- Pens.cs
- TextCompositionEventArgs.cs
- PerfProviderCollection.cs
- _SecureChannel.cs
- PtsPage.cs
- EventProxy.cs
- BasicExpressionVisitor.cs
- CatalogPartChrome.cs
- SystemWebExtensionsSectionGroup.cs
- SetterBaseCollection.cs
- VisualStyleRenderer.cs
- TabControlDesigner.cs
- PlainXmlDeserializer.cs
- ExpressionBuilderContext.cs
- DesignerActionUIService.cs
- RSAOAEPKeyExchangeFormatter.cs
- xml.cs
- AccessedThroughPropertyAttribute.cs
- HtmlPhoneCallAdapter.cs
- CheckBoxRenderer.cs
- RequestCachePolicyConverter.cs
- WhitespaceRuleReader.cs
- EnvironmentPermission.cs
- CompositeTypefaceMetrics.cs
- RedirectionProxy.cs
- CodeAttributeArgument.cs
- RectValueSerializer.cs
- WindowsScroll.cs
- TypeGenericEnumerableViewSchema.cs
- CommonGetThemePartSize.cs
- XPathDescendantIterator.cs
- QueryStoreStatusRequest.cs
- CalendarModeChangedEventArgs.cs
- ReferencedAssembly.cs
- UnsafeNativeMethods.cs
- MSG.cs
- Effect.cs
- Compiler.cs
- EmptyStringExpandableObjectConverter.cs
- PerformanceCounterPermission.cs
- RadioButtonRenderer.cs
- SR.cs
- InArgument.cs
- GenericTypeParameterBuilder.cs
- ClientProtocol.cs
- CharEnumerator.cs
- ConstraintCollection.cs
- KnownBoxes.cs
- BadImageFormatException.cs
- ScalarType.cs
- Operand.cs
- BitmapEffectvisualstate.cs
- ReflectionTypeLoadException.cs
- LogSwitch.cs