Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 // constructor for many-to-many select
 public SpecialLinqCommand(EntitySession session, string sqlCacheKey,
                           ChildEntityListInfo listInfoManyToMany, List <EntityKeyMemberInfo> orderBy,
                           object[] paramValues, Action <SpecialLinqCommand> setupAction)
     : base(session, LinqCommandKind.Special, LinqOperation.Select)
 {
     this.SqlCacheKey   = sqlCacheKey;
     ListInfoManyToMany = listInfoManyToMany;
     OrderBy            = orderBy;
     ParamValues        = paramValues;
     SetupAction        = setupAction;
     base.LockType      = LockType.None;
 }
Esempio n. 3
0
        public EntityCommand BuildSelectTargetListManyToManyCommand(ChildEntityListInfo listInfo)
        {
            //for many to many, create command selecting real entities
            var targetEnt    = listInfo.TargetEntity;
            var parentEnt    = listInfo.ParentRefMember.Entity;
            var parentRefKey = listInfo.ParentRefMember.ReferenceInfo.FromKey; //FK from link entity to parent entity
            var cmdName      = targetEnt.Name + "_SelectBy_" + listInfo.LinkEntity.Name + "_" + listInfo.ParentRefMember.MemberName;
            var cmd          = AddCommand(cmdName, "Selects entities by many-to-many link.", EntityCommandKind.SelectByKeyManyToMany, targetEnt, parentRefKey);

            cmd.SelectKeySecondary = listInfo.OtherEntityRefMember.ReferenceInfo.FromKey;
            AddParametersFromKey(cmd, cmd.SelectKey);
            return(cmd);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 public EntityCommand BuildSelectTargetListManyToManyCommand(ChildEntityListInfo listInfo)
 {
     //for many to many, create command selecting real entities
       var targetEnt = listInfo.TargetEntity;
       var parentEnt = listInfo.ParentRefMember.Entity;
       var parentRefKey = listInfo.ParentRefMember.ReferenceInfo.FromKey; //FK from link entity to parent entity
       var cmdName = targetEnt.Name + "_SelectBy_" + listInfo.LinkEntity.Name + "_" + listInfo.ParentRefMember.MemberName;
       var cmd = AddCommand(cmdName, "Selects entities by many-to-many link.", EntityCommandKind.SelectByKeyManyToMany, targetEnt, parentRefKey);
       cmd.SelectKeySecondary = listInfo.OtherEntityRefMember.ReferenceInfo.FromKey;
       AddParametersFromKey(cmd, cmd.SelectKey);
       return cmd;
 }