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
- ReachObjectContext.cs
- TCEAdapterGenerator.cs
- PageSettings.cs
- ItemContainerGenerator.cs
- DBAsyncResult.cs
- ToolboxDataAttribute.cs
- AccessDataSourceView.cs
- XmlSchemaComplexContentExtension.cs
- RadioButtonAutomationPeer.cs
- WebPart.cs
- FilterFactory.cs
- WSHttpBindingCollectionElement.cs
- NetworkAddressChange.cs
- util.cs
- GridViewPageEventArgs.cs
- AttachedAnnotation.cs
- Scripts.cs
- Span.cs
- ExtensibleClassFactory.cs
- AlternationConverter.cs
- IsolatedStorageFile.cs
- LoginCancelEventArgs.cs
- TypedDataSetSchemaImporterExtension.cs
- ListViewItemCollectionEditor.cs
- InstanceDataCollection.cs
- AutoResetEvent.cs
- EndpointDiscoveryMetadata.cs
- UserControlCodeDomTreeGenerator.cs
- SchemaNames.cs
- AssemblyCache.cs
- SurrogateSelector.cs
- SqlRecordBuffer.cs
- FixedStringLookup.cs
- ServiceReference.cs
- XmlSchemaSimpleTypeRestriction.cs
- Transform3DGroup.cs
- DesignTable.cs
- UpDownBase.cs
- RouteParametersHelper.cs
- ClientProxyGenerator.cs
- CreateUserErrorEventArgs.cs
- OutputCacheSettings.cs
- CharacterBufferReference.cs
- HashHelper.cs
- HotSpotCollection.cs
- TransformerTypeCollection.cs
- SqlDelegatedTransaction.cs
- DBNull.cs
- EntityTemplateUserControl.cs
- DataBinding.cs
- CompletionCallbackWrapper.cs
- FormsAuthenticationTicket.cs
- Mapping.cs
- CompositeDispatchFormatter.cs
- ImageDesigner.cs
- ScaleTransform.cs
- OrderByLifter.cs
- AffineTransform3D.cs
- MemberHolder.cs
- OrCondition.cs
- ByteStorage.cs
- DSASignatureFormatter.cs
- ButtonColumn.cs
- AvTraceFormat.cs
- DuplicateWaitObjectException.cs
- TagMapInfo.cs
- TraceContextEventArgs.cs
- DataGridViewImageColumn.cs
- CompilerResults.cs
- DataSet.cs
- XmlLoader.cs
- HeaderedItemsControl.cs
- PointCollection.cs
- TypeElementCollection.cs
- Substitution.cs
- Group.cs
- ImplicitInputBrush.cs
- TextEditorCharacters.cs
- XmlUtil.cs
- nulltextcontainer.cs
- ApplicationId.cs
- Sql8ConformanceChecker.cs
- OrthographicCamera.cs
- PagesSection.cs
- GifBitmapDecoder.cs
- XmlSchemaFacet.cs
- XmlNodeList.cs
- HashHelper.cs
- MsmqAppDomainProtocolHandler.cs
- SessionStateSection.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- SiteMapNodeItem.cs
- StateBag.cs
- ConstraintConverter.cs
- __Error.cs
- XPathDocumentNavigator.cs
- HttpRawResponse.cs
- WriteableOnDemandPackagePart.cs
- CopyCodeAction.cs
- XmlChoiceIdentifierAttribute.cs