Exemplo n.º 1
0
 public TableDeclarationClause GetTableDeclaration(QueryEntity entity)
 {
     return(entity.declaration
            ?? (entity.declaration = new TableDeclarationClause
     {
         Name = entity.mapping.DbTableName,
         Alias = nameGenerator.GenerateTableName()
     }));
 }
Exemplo n.º 2
0
        public JoinClause GetJoinSql(QueryEntity enumEntity)
        {
            if (!enumEntity.mapping.ObjectName.HasValue)
            {
                throw new InvalidOperationException("assertion failure");
            }
            var declaration = new TableDeclarationClause
            {
                Name  = "simple1c.enumMappings",
                Alias = nameGenerator.GenerateTableName()
            };

            return(new JoinClause
            {
                Source = declaration,
                JoinKind = JoinKind.Left,
                Condition = new AndExpression
                {
                    Left = new EqualityExpression
                    {
                        Left = new ColumnReferenceExpression
                        {
                            Name = "enumName",
                            Table = declaration
                        },
                        Right = new LiteralExpression
                        {
                            Value = enumEntity.mapping.ObjectName.Value.Name.ToLower()
                        }
                    },
                    Right = new EqualityExpression
                    {
                        Left = new ColumnReferenceExpression
                        {
                            Name = "orderIndex",
                            Table = declaration
                        },
                        Right = new ColumnReferenceExpression
                        {
                            Name = enumEntity.GetSingleColumnName("Порядок"),
                            Table = queryEntityTree.GetTableDeclaration(enumEntity)
                        }
                    }
                }
            });
        }