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
- RSAPKCS1SignatureDeformatter.cs
- ColumnClickEvent.cs
- DBSqlParserColumnCollection.cs
- SelectionEditor.cs
- IEnumerable.cs
- MinimizableAttributeTypeConverter.cs
- QuaternionAnimationUsingKeyFrames.cs
- Unit.cs
- CleanUpVirtualizedItemEventArgs.cs
- SqlDependencyListener.cs
- PropertyRecord.cs
- SHA512Managed.cs
- DataSetUtil.cs
- SecuritySessionSecurityTokenProvider.cs
- FirstMatchCodeGroup.cs
- OrderedDictionaryStateHelper.cs
- Point.cs
- Number.cs
- DynamicValidator.cs
- CookieProtection.cs
- TransformerConfigurationWizardBase.cs
- UpdateTracker.cs
- StorageAssociationSetMapping.cs
- UrlRoutingModule.cs
- Semaphore.cs
- WorkflowLayouts.cs
- ObjectManager.cs
- IdentityManager.cs
- TargetControlTypeCache.cs
- AssemblyAssociatedContentFileAttribute.cs
- COM2PropertyDescriptor.cs
- ImmComposition.cs
- IndentTextWriter.cs
- SecurityCookieModeValidator.cs
- PeerNodeTraceRecord.cs
- SqlParameter.cs
- DiscoveryMessageSequenceCD1.cs
- EdmProviderManifest.cs
- VisualStyleElement.cs
- RelationshipWrapper.cs
- DataGridHeaderBorder.cs
- HttpSocketManager.cs
- NavigationWindowAutomationPeer.cs
- Crc32Helper.cs
- SimpleBitVector32.cs
- TableLayoutStyleCollection.cs
- MaskedTextBoxTextEditor.cs
- GridErrorDlg.cs
- PersonalizationDictionary.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- sqlinternaltransaction.cs
- Profiler.cs
- ArrayHelper.cs
- EntityDesignerUtils.cs
- TemplateNameScope.cs
- FormViewDeletedEventArgs.cs
- WebSysDisplayNameAttribute.cs
- ExpressionList.cs
- Identity.cs
- TableParaClient.cs
- ToolStripSettings.cs
- OracleCommand.cs
- XPathNavigatorKeyComparer.cs
- RequestSecurityTokenForGetBrowserToken.cs
- TabletDeviceInfo.cs
- ToolboxItemCollection.cs
- ArgIterator.cs
- ResourceKey.cs
- GenerateDerivedKeyRequest.cs
- BuildProviderCollection.cs
- FullTextLine.cs
- DataRowChangeEvent.cs
- RequestTimeoutManager.cs
- ConstructorExpr.cs
- TcpSocketManager.cs
- FileSystemEventArgs.cs
- controlskin.cs
- TabControlCancelEvent.cs
- FormsAuthenticationModule.cs
- TimelineGroup.cs
- ZipQueryOperator.cs
- SequenceDesigner.cs
- EmptyStringExpandableObjectConverter.cs
- TableColumn.cs
- CellTreeNode.cs
- MailHeaderInfo.cs
- RewritingValidator.cs
- SecurityRuntime.cs
- FormViewDeleteEventArgs.cs
- ObjectNavigationPropertyMapping.cs
- GACIdentityPermission.cs
- SqlParameter.cs
- OdbcUtils.cs
- InputLanguageCollection.cs
- EditModeSwitchButton.cs
- LassoSelectionBehavior.cs
- XmlAutoDetectWriter.cs
- Point4D.cs
- ImageCodecInfo.cs
- ReferencedCollectionType.cs