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
- BitmapMetadataBlob.cs
- AudioLevelUpdatedEventArgs.cs
- SharedPersonalizationStateInfo.cs
- DrawListViewItemEventArgs.cs
- ProtocolsSection.cs
- VisualStyleRenderer.cs
- MemberDomainMap.cs
- PeerPresenceInfo.cs
- HashSet.cs
- ContentValidator.cs
- BooleanAnimationUsingKeyFrames.cs
- AsyncCallback.cs
- FragmentQueryProcessor.cs
- Events.cs
- WindowInteropHelper.cs
- ProfileBuildProvider.cs
- FastPropertyAccessor.cs
- CreateParams.cs
- DeploymentSectionCache.cs
- MetadataArtifactLoaderResource.cs
- Polygon.cs
- JsonReaderDelegator.cs
- XmlAtomicValue.cs
- XmlSchemaInclude.cs
- IHttpResponseInternal.cs
- InputLanguageManager.cs
- ControlCachePolicy.cs
- WebPartConnectionsConfigureVerb.cs
- WebPartDisplayModeCollection.cs
- SystemIcmpV6Statistics.cs
- XmlSerializerAssemblyAttribute.cs
- ImageDrawing.cs
- Pkcs9Attribute.cs
- BufferedWebEventProvider.cs
- SqlOuterApplyReducer.cs
- SqlConnectionFactory.cs
- IsolatedStorage.cs
- TryExpression.cs
- ExceptionUtil.cs
- UrlPropertyAttribute.cs
- UnknownBitmapDecoder.cs
- SiteMapPath.cs
- ResolveMatches11.cs
- TreeViewItem.cs
- WorkflowFileItem.cs
- DataGridViewButtonCell.cs
- SQLString.cs
- PropertyEmitter.cs
- EncoderNLS.cs
- SchemaInfo.cs
- BitmapFrameDecode.cs
- MimeBasePart.cs
- Win32.cs
- XmlTypeMapping.cs
- ListControl.cs
- TextTreeNode.cs
- OutputChannelBinder.cs
- SortDescriptionCollection.cs
- PipeStream.cs
- HtmlHead.cs
- UrlMappingCollection.cs
- ConnectionManagementSection.cs
- TextContainerChangedEventArgs.cs
- CookielessData.cs
- DataGridTableCollection.cs
- ToolStripSettings.cs
- SiteMapDesignerDataSourceView.cs
- WorkflowMessageEventHandler.cs
- updateconfighost.cs
- DNS.cs
- DataGridViewBand.cs
- UniformGrid.cs
- DataGridViewCellMouseEventArgs.cs
- AttributeQuery.cs
- ReflectEventDescriptor.cs
- ModelEditingScope.cs
- RoleManagerSection.cs
- X509ChainElement.cs
- SiteIdentityPermission.cs
- DiscoveryClientOutputChannel.cs
- NopReturnReader.cs
- OrthographicCamera.cs
- UnlockInstanceCommand.cs
- XmlValidatingReader.cs
- diagnosticsswitches.cs
- GridSplitterAutomationPeer.cs
- SchemaName.cs
- WindowsFormsHost.cs
- DispatcherObject.cs
- URL.cs
- RegionInfo.cs
- SizeChangedEventArgs.cs
- WebPartConnectionsCancelEventArgs.cs
- DeploymentExceptionMapper.cs
- IDispatchConstantAttribute.cs
- DateTime.cs
- DataGridTableStyleMappingNameEditor.cs
- RoutedPropertyChangedEventArgs.cs
- ZipIORawDataFileBlock.cs
- ToolStripContentPanelRenderEventArgs.cs