Exemple #1
0
        public SingleParameterLambdaState(ParameterExpression parameter)
        {
            this.singleEntityName = parameter.Name;
            Type type = parameter.Type;
            DataEntityMapping entityMapping = DataEntityMapping.GetEntityMapping(type);

            this.singleEntityMap = entityMapping.GetRelationMap();
        }
Exemple #2
0
        public virtual QueryCommand SelectInsert(DataContext context, InsertSelector selector, DataEntityMapping mapping, QueryExpression query, OrderExpression order, bool distinct)
        {
            RelationMap    relationMap = mapping.GetRelationMap();
            CommandData    commandData;
            CreateSqlState state = new CreateSqlState(context);

            if (mapping.HasJoinRelateModel)
            {
                QueryExpression subQuery  = null;
                QueryExpression mainQuery = null;
                OrderExpression subOrder  = null;
                OrderExpression mainOrder = null;
                if (query != null)
                {
                    if (query.MutliQuery)
                    {
                        mainQuery = query;
                    }
                    else
                    {
                        subQuery = query;
                    }
                }
                if (order != null)
                {
                    if (order.MutliOrder)
                    {
                        mainOrder = order;
                    }
                    else
                    {
                        subOrder = order;
                    }
                }
                List <IJoinModel> models = relationMap.CreateJoinModels(subQuery, subOrder);
                commandData = _factory.CreateSelectInsertCommand(selector, models, mainQuery, mainOrder, distinct, state);
            }
            else
            {
                commandData = _factory.CreateSelectInsertCommand(selector, mapping, query, order, distinct, state);
            }
            DbCommand    command      = commandData.CreateCommand(this, state);
            QueryCommand queryCommand = new QueryCommand()
            {
                Command = command
            };

            return(queryCommand);
        }
Exemple #3
0
        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);
        }