Click or drag to resize

LinqUtils Class

Class which embeds utility methods for linq support
Inheritance Hierarchy
SystemObject
  SD.LLBLGen.Pro.LinqSupportClassesLinqUtils

Namespace:  SD.LLBLGen.Pro.LinqSupportClasses
Assembly:  SD.LLBLGen.Pro.ORMSupportClasses (in SD.LLBLGen.Pro.ORMSupportClasses.dll) Version: 5.4.0.0 (5.4.0)
Syntax
public static class LinqUtils

The LinqUtils type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAddFieldToProjectionIfNotPresent
Adds the field to projection if not present already. If the projection is an entity projection, only the field aliases are compared. If the projection is a valuelist projection, field alias and field objectalias are compared.
Public methodStatic memberAddFromClauseDirectivesToRelationsCollection
Adds the specified from clause directives to the relation collection specified. If the relation collection is null and there are from clause directives to add, a new relation collection is created.
Public methodStatic memberAddPathEdgesToPrefetchPath
Adds the path edge to the prefetch path passed in.
Public methodStatic memberAddPathEdgesToPrefetchPathElement
Adds the path edges to prefetch path element.
Public methodStatic memberAddRelationsRangeToRelationsCollection
Adds the relations range in source to the relations collection called destination. If destination is null and source is not empty, a new relationcollection is returned with source's relations added to it.
Public methodStatic memberCalculateRowHashForSpecifiedValues
Calculates the row hash from the values at the specified indices
Public methodStatic memberCheckIfImplicitCast
Checks if the cast from fromType to toType is an implicit cast.
Public methodStatic memberCheckifJoinIsFullQuery
Checks if the passed in join is a full query or just a join. It's a full query if the projection lambda has as output type not a type which is build from the two input types.
Public methodStatic memberCloneField(IEntityFieldCore)
Clones the field passed in.
Public methodStatic memberCloneField(IEntityFieldCore, Boolean)
Clones the field passed in.
Public methodStatic memberCoerceBooleanExpressionToDbFunctionCallParameter
Coerces the boolean expression to a db function call parameter.
Public methodStatic memberCoercePredicateToPredicateExpression
Coerces the predicate to predicate expression.
Public methodStatic memberCoerceSetReferenceExpressionToEntityFieldExpressionIfRequired
Coerces the set reference expression to entity field expression if required.
Public methodStatic memberCoerceToSet
Coerces the passed in linq expression to setexpression. If the passed in expression is a parameter, it will convert it to a setreference expression otherwise it will try to cast it to a setexpression. If this can't be done, in the situation where tocoerce isn't a setexpression, null is returned.
Public methodStatic memberCoerceToType
Coerces the linq expression to the targettype.
Public methodStatic memberConvertLocalExpressionToRealObject
Converts the local expression to a real object. This is done by a trick: we'll compile the whole expression as a lambda and run it. this will return the object, including initialization results and completely materialized as we want it. The passed in expression is for example a list or array initialization / ctor call. To utilize the in-memory object, we've to run this ctor to be able to use the values. This routine takes care of that.
Public methodStatic memberCorrectRenamedFieldIfRequired
Corrects the field's name if it targets a renamed field in a derived set.
Public methodStatic memberCreateBoolProducerLambda
Creates a bool producer lambda which is usable in projections via the ProjectionValueProducerFunc delegate.
Public methodStatic memberCreateConstantBoolPredicate
Creates a constant false predicate. This predicate results in a @param=0 predicate, where the param has a value of 1.
Public methodStatic memberCreateDbFunctionCallAsLLBLExpression(DbFunctionCallExpression, IRelationCollection, Object)
Creates a new DbFunctionCall object and wraps it inside a LLBLGenProExpressionExpression object.
Public methodStatic memberCreateDbFunctionCallAsLLBLExpression(Type, FunctionMapping, IRelationCollection, Object)
Creates a new DbFunctionCall object and wraps it inside a LLBLGenProExpressionExpression object.
Public methodStatic memberCreateDerivedTable
Creates a derived table definition from the expression to convert.
Public methodStatic memberCreateEntityInstanceFromEntityType
Creates a new entity instance from the type specified. This routine uses a factory related to the type, not Activator, as some abstract entities may be used which don't have a public ctor. Falls back to activator if type is a custom type derived from an entity class.
Public methodStatic memberCreateHashValueKeyFromIndices
Creates the hash value key from indices.
Public methodStatic memberCreateObjectCreatorFuncInstanceTObject
Creates the object creator func instance for instantiating objects of type TObject using the default constructor
Public methodStatic memberCreateObjectCreatorFuncInstanceTObject(ConstructorInfo)
Creates the object creator func instance for instantiating objects of type TObject using the constructor passed in.
Public methodStatic memberCreatePkfieldPkFieldFilterFromEntity
Creates a filter which compares the PK fields of the entity type passed in, for both aliases passed in, so: aliasWrappedSet.PkField1 = aliasNestedSet.PkField1 AND ... aliasWrappedSet.PkFieldn = aliasNestedSet.PkFieldn
Public methodStatic memberCreatePkFilterFromEntity
Creates a pk filter on the PK fields of the passed in entity with the values in the passed in entity. The objectAlias is the alias of the set to filter.
Public methodStatic memberCreatePredicate(Object, ComparisonOperator, Object, ITemplateGroupSpecificCreator)
Creates a predicate based on the imput specified.
Public methodStatic memberCreatePredicate(IEntityFieldCore, ComparisonOperator, Object, ITemplateGroupSpecificCreator)
Creates a predicate based on the imput specified.
Public methodStatic memberCreatePredicateExpressionFromCorrelationRelation(IEntityRelation, ITemplateGroupSpecificCreator, MappingTracker)
Creates a predicate expression from the correlation relation passed in. It aliases all fields to the start/end alias set, and creates field compare field predicates (FieldCompareExpression instances) which are added with AND to the expression to return
Public methodStatic memberCreatePredicateExpressionFromCorrelationRelation(IEntityRelation, ITemplateGroupSpecificCreator, MappingTracker, ListIEntityFieldCore)
Creates a predicate expression from the correlation relation passed in. It aliases all fields to the start/end alias set, and creates field compare field predicates (FieldCompareExpression instances) which are added with AND to the expression to return
Public methodStatic memberCreateProjectionLambdaForTypedViewExpression
Creates a p=>new T() { A = p.A, B=p.B, ...} expression for toWrap. Only fields of the typed view which have a corresponding property in the return type of toWrap are considered.
Public methodStatic memberCreateProperReferenceFieldFromSourceFieldFromProjection
Creates the proper reference field from source field from projection.
Public methodStatic memberCreateScalarQueryFromQueryExpression
Creates a scalarqueryexpression object from the query passed in.
Public methodStatic memberCreateUsableDbFunctionCallParameterValue
Creates a usable db function call parameter value from the expression passed in.
Public methodStatic memberDetermineComparisonOperatorForPredicate
Determines the comparison operator for predicate from the operands passed in.
Public methodStatic memberDetermineDifferentValuesForNestedQueryFilter
Determines the different values for nested query filter. This set of values is then used to build a parameterized query if possible.
Public methodStatic memberDetermineEntityTypeFromEntityCollectionType
Determines the type of the entity type from entity collection.
Public methodStatic memberDetermineEntityTypeFromMemberExpression
Gets the entity type from member. Assumes the member is either an entity or a collection and the member is defined on an entity
Public methodStatic memberDetermineEntityTypeFromSetExpression
Determines the entity type from passed in set expression.
Public methodStatic memberDetermineEntityTypeFromType
Determines the type of the entity type from the type passed in.
Public methodStatic memberDetermineInheritanceHierarchyTypeOfEntity
Determines the inheritance hierarchy type of entity.
Public methodStatic memberDetermineSetElementType(Type)
Determines the type of the elements in the set which type is passed in.
Public methodStatic memberDetermineSetElementType(Type, Boolean)
Determines the type of the elements in the set which type is passed in.
Public methodStatic memberGetAllFieldsForEntity
Gets all fields for entity.
Public methodStatic memberGetAllFieldsFromProjection
Gets all fields from projection.
Public methodStatic memberGetAllPkFieldsOfEntity(IEntityCore, Boolean)
Gets all the pk fields of entity.
Public methodStatic memberGetAllPkFieldsOfEntity(Type, IElementCreatorCore, Boolean)
Gets all pk fields of entity.
Public methodStatic memberGetElementCreator
Gets the element creator stored in the provider in the passed in queryable.
Public methodStatic memberGetEntityFactoryT
Gets the entity factory for the entity type specified. Applies null checks with gracious error reporting for better clarity why it failed.
Public methodStatic memberGetEntityName
Gets the name of the entity. If value is a string, value is returned as the string, if value is a type, GetEntityNameFromType is used to obtain the name
Public methodStatic memberGetEntityNameFromType
Gets the name of the entity of the entity which type has been passed in.
Public methodStatic memberGetEntityTypeEnumAsIntFromType
Gets the EntityType enum value as integer of the entity with the type specified.
Public methodStatic memberGetFieldObject(IEntityCore, String)
Gets the field object with the name passed in from the entity specified.
Public methodStatic memberGetFieldObject(IEntityCore, String, Boolean)
Gets the field object with the name passed in from the entity specified.
Public methodStatic memberGetFieldObjectAndSetObjectAlias
Gets the field object from the entity passed in and sets its ObjectAlias to the alias passed in.
Public methodStatic memberGetFirstFieldInProjection
Gets the first field in projection.
Public methodStatic memberGetTypeOfValue
Gets the type of value.
Public methodStatic memberGrabFirstUsuableFieldInProjection
Grabs the first usable field in the projection definition passed in. For entity projections, this is the *last* field as due to inheritance it can be the first field is in the root of the hierarchy. For the caller this shouldn't matter.
Public methodStatic memberIsNullableOfT
Determines whether the passed in type is a nullable(Of T) type. If so, true is returned, otherwise false
Public methodStatic memberIsSingleValueType
Determines whether the type passed in is a value type or a type which is a single value and thus should be considered a type a field could have.
Public methodStatic memberObtainObjectValuesFromListOfObjects
Obtains the object values for all fields in the list of fields specified from list of objects passed in.
Public methodStatic memberObtainPkValuesFromListOfEntities
Obtains the pk values from list of entities. It creates a new array, with listOfEntities.Count rows and fields.Count columns.
Public methodStatic memberObtainRealValueFromConstantWrapped
Obtains the real value from constant expression and wrap it again in a ConstantExpression. The 'real' value is the value of the object referred to by the constant, e.g. an object property.
Public methodStatic memberObtainTypeFilterForEntity
Obtains the type filter for the entity with the type specified.
Public methodStatic memberObtainValidFieldFromEntity(Type, IElementCreatorCore)
Obtains a valid field from the entity of which the type is passed in. A valid field is a field which is located in that entity and also defined in that entity so not inherited from a supertype.
Public methodStatic memberObtainValidFieldFromEntity(Type, IElementCreatorCore, String)
Obtains a valid field from the entity of which the type is passed in. A valid field is a field which is located in that entity and also defined in that entity so not inherited from a supertype.
Public methodStatic memberProduceBooleanProducerLambdaFromBooleanTypedExpression
Produces the boolean producer lambda from boolean typed expression (which can be a filter or an LLBLGen expression with boolean operator) boolean expression in projection means it has to be wrapped inside a scalarquery expression which should be wrapped inside a field which then should be the parameter of a dbfunction call which represents a CASE statement. This db function call's result has to be processed by a lambda which checks if the dbfunction call's case statement returned 1 or 0 and returns true or false.
Public methodStatic memberProduceInvocationLambdaFromInvocationExpression
Produces an invocation lambda from the invocation expression passed in. It wraps the realLambda into a (values, indices) => realLambda(values[indexes[0]], values[indexes[1]], ...) call.
Public methodStatic memberProduceProperBooleanExpressionLambda
Produces the proper boolean expression lambda, from the passed in lambda. If the passed in lambda's return type isn't bool it's returned as-is. Otherwise, it's checked whether it contains a boolean expression. If not, it's corrected. If it does, it's returned as-is.
Public methodStatic memberRemoveConvertExpressionWrappers
Removes the convert expression wrappers, which are Unary expression which are simply Convert expression but don't do anything really useful.
Public methodStatic memberRemovePredicatesFromFilter
Removes the passed in predicates from the filter to clean.
Public methodStatic memberRemoveUnaryQuoteExpressionWrappers
Removes the unary quote expression wrappers. Some unary expressions are wrapped in Unary expressions which are of type Quote, and which simply wrap an inner expression. This method unwraps the inner expression, as we're not interested in the wrapper.
Public methodStatic memberReplaceFirstFieldInProjection
Replaces the first field in project.
Public methodStatic memberSafeExpressionToString
returns the string representation of the element passed in or "(null)" if null.
Public methodStatic memberSetProperHintForJoin
Sets the proper hint for join in the relation passed in. It will set it to left join if the start entity is the fk side and the fk is nullable In all other cases it will stay Inner. It doesn't matter if the start entity is the PK side and the FK side is nullable: a left join or inner join will result in the same resultset. We can't do a right-join here as that would join towards the related entity and it would lead to nulls in the start entity which is the start of the navigation.
Public methodStatic memberStripOutProjectionFromJoinResultExpression
Strips out the projection from join result expression.
Public methodStatic memberUnwrapNotExpression
Unwraps the expression from the not expressions it is wrapped in and returns the unwrapped result, as well as the # of not expressions encountered.
Public methodStatic memberValuesAreEqual
Compares two values based on their values using the ORMSupportClasses routine in FieldUtilities. This method is here to avoid breakage of Linq code without noticing it if the signature of the ORMSupportClasses routine changes. This routine has no code of its own, it simply calls into the FieldUtilities.ValuesAreEqual routine
Public methodStatic memberWrapProjectionElementInSelectIfRequired
Wraps the projection element in select passed in if required. This is necessary if the expression is an entity expression and it has a correlationrelation which means that the projection element contains a reference to a related entity which will result in a nested query.
Top
See Also