public virtual QueryCommand QueryEntityData(DataContext context, DataEntityMapping mapping, ISelector selector, QueryExpression query, OrderExpression order, bool distinct, Region region) { RelationMap relationMap = mapping.GetRelationMap(); if (selector == null) { selector = relationMap.GetDefaultSelector(); } CreateSqlState state = new CreateSqlState(context); CommandData commandData = _factory.CreateSelectDataCommand(mapping, relationMap, selector, query, order, distinct, region, state); DbCommand command = commandData.CreateCommand(this, state); QueryState queryState = new QueryState(); queryState.SetRelationMap(relationMap); queryState.SetSelector(selector); QueryCommand queryCommand = new QueryCommand() { Command = command, InnerPage = commandData.InnerPage, State = queryState }; return(queryCommand); }