public static SpecialLinqCommand CreateCheckAnyChildRecords(EntityKeyInfo childKey, EntityRecord record) { childKey.SqlCacheKey_ChildExists = childKey.SqlCacheKey_ChildExists ?? SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_ExistsByKey, childKey.Entity.Name, childKey.Name, LockType.None, null); return(new SpecialLinqCommand(record.Session, childKey.SqlCacheKey_ChildExists, childKey, LockType.None, null, record.PrimaryKey.Values, Setup_CheckChildExists)); }
public static SpecialLinqCommand CreateSelectByKeyValueArray(EntitySession session, EntityKeyInfo key, List <EntityKeyMemberInfo> orderBy, IList keyValues) { var sqlCacheKey = SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_SelectByKeyArray, key.Entity.Name, key.Name, LockType.None, orderBy); // build the command var paramValues = new object[] { keyValues }; return(new SpecialLinqCommand(session, sqlCacheKey, key, LockType.None, orderBy, paramValues, Setup_SelectByKeyValueArray)); }
public static SpecialLinqCommand CreateSelectByKeyForListPropertyManyToMany(EntitySession session, ChildEntityListInfo listInfo, object[] keyValues) { Util.Check(listInfo.RelationType == EntityRelationType.ManyToMany, "Fatal: expected many-to-many list."); var fromKey = listInfo.ParentRefMember.ReferenceInfo.FromKey; listInfo.SqlCacheKey_SelectChildRecs = listInfo.SqlCacheKey_SelectChildRecs ?? SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_SelectByKeyListPropertyManyToMany, fromKey.Entity.Name, fromKey.Name, LockType.None, null); return(new SpecialLinqCommand(session, listInfo.SqlCacheKey_SelectChildRecs, listInfo, listInfo.OrderBy, keyValues, Setup_SelectManyToMany)); }
public static SpecialLinqCommand CreateSelectByKeyArrayForListPropertyManyToOne(EntitySession session, ChildEntityListInfo listInfo, IList keyValues) { Util.Check(listInfo.RelationType == EntityRelationType.ManyToOne, "Fatal: expected many-to-one list."); var fromKey = listInfo.ParentRefMember.ReferenceInfo.FromKey; listInfo.SqlCacheKey_SelectChildRecsForInclude = listInfo.SqlCacheKey_SelectChildRecsForInclude ?? SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_SelectByKeyArrayListPropertyManyToOne, fromKey.Entity.Name, fromKey.Name, LockType.None, null); // it is simply select-by-key-array command var orderBy = fromKey.ExpandedKeyMembers.Merge(listInfo.OrderBy); var paramValues = new object[] { keyValues }; return(new SpecialLinqCommand(session, listInfo.SqlCacheKey_SelectChildRecsForInclude, fromKey, LockType.None, orderBy, paramValues, Setup_SelectByKeyValueArray)); }
// for special linq commands: to avoid regenerating sql cache key we 'cache' it inside Key or ListInfo meta objects public static SpecialLinqCommand CreateSelectByPrimaryKey(EntitySession session, EntityKeyInfo key, LockType lockType, object[] keyValues) { // get sql cache key - we cache it inside KeyInfo only for no-lock queries string sqlCacheKey; if (lockType == LockType.None) { sqlCacheKey = key.SqlCacheKey_SelectByPkNoLock = key.SqlCacheKey_SelectByPkNoLock ?? SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_SelectByPk, key.Entity.Name, key.Name, LockType.None, null); } else { sqlCacheKey = SqlCacheKeyBuilder.BuildSpecialSelectKey(Tag_SelectByPk, key.Entity.Name, key.Name, lockType, null); } // build the command return(new SpecialLinqCommand(session, sqlCacheKey, key, lockType, null, keyValues, Setup_SelectByKey)); }
private void AnalyzeCommand(DynamicLinqCommand command) { _command = command; _model = command.Session.Context.App.Model; _cacheKeyBuilder = new SqlCacheKeyBuilder("Linq", command.Kind.ToString(), command.Operation.ToString()); try { AnalyzeNode(_command.QueryExpression); //copy some values to command command.SqlCacheKey = _cacheKeyBuilder.Key; command.EntityTypes = _entityTypes; command.LockType = _lockType; command.Includes = _includes; command.Options |= _options; command.Locals.AddRange(_locals); command.ExternalParameters = _externalParams?.ToArray(); if (command.Locals.Count > 0) { LinqExpressionHelper.EvaluateLocals(command); } } catch (Exception ex) { ex.Data["LinqExperssion"] = _command.QueryExpression + string.Empty; throw; } }