示例#1
0
 public static void RunIncludeQueries(IEntitySession session, LinqCommand command, object mainQueryResult)
 {
     // initial checks if there's anything to run
       var resultShape = command.Info.ResultShape;
       if (mainQueryResult == null || resultShape == QueryResultShape.Object)
     return;
       var allIncludes = session.Context.GetMergedIncludes(command.Info.Includes);
       if (allIncludes.Count == 0)
     return;
       // Get records from query result
       var records = new List<EntityRecord>();
       switch (resultShape) {
     case QueryResultShape.Entity:
       records.Add(EntityHelper.GetRecord(mainQueryResult));
       break;
     case QueryResultShape.EntityList:
       var list = mainQueryResult as IList;
       if (list.Count == 0)
     return;
       foreach (var ent in list)
     records.Add(EntityHelper.GetRecord(ent));
       break;
       }//switch;
       // actually run the includes
       var entityType = records[0].EntityInfo.EntityType;
       var helper = new IncludeQueryHelper(session, allIncludes);
       helper.RunIncludeQueries(entityType, records);
 }
示例#2
0
        public static void RunIncludeQueries(IEntitySession session, LinqCommand command, object mainQueryResult)
        {
            // initial checks if there's anything to run
            var resultShape = command.Info.ResultShape;

            if (mainQueryResult == null || resultShape == QueryResultShape.Object)
            {
                return;
            }
            var allIncludes = session.Context.GetMergedIncludes(command.Info.Includes);

            if (allIncludes.Count == 0)
            {
                return;
            }
            // Get records from query result
            var records = new List <EntityRecord>();

            switch (resultShape)
            {
            case QueryResultShape.Entity:
                records.Add(EntityHelper.GetRecord(mainQueryResult));
                break;

            case QueryResultShape.EntityList:
                var list = mainQueryResult as IList;
                if (list.Count == 0)
                {
                    return;
                }
                foreach (var ent in list)
                {
                    records.Add(EntityHelper.GetRecord(ent));
                }
                break;
            }//switch;
            // actually run the includes
            var entityType = records[0].EntityInfo.EntityType;
            var helper     = new IncludeQueryHelper(session, allIncludes);

            helper.RunIncludeQueries(entityType, records);
        }