System.Data.SQLite
Hex Artifact Content
Not logged in

Artifact 55be6a85f0e4527a0b3191626de8c09963517551:


0000: 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  //--------------
0010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0040: 2d 2d 2d 2d 2d 2d 2d 0d 0a 2f 2f 20 3c 63 6f 70  -------..// <cop
0050: 79 72 69 67 68 74 20 66 69 6c 65 3d 22 53 79 6d  yright file="Sym
0060: 62 6f 6c 50 61 69 72 2e 63 73 22 20 63 6f 6d 70  bolPair.cs" comp
0070: 61 6e 79 3d 22 4d 69 63 72 6f 73 6f 66 74 22 3e  any="Microsoft">
0080: 0d 0a 2f 2f 20 20 20 20 20 20 50 6f 72 74 69 6f  ..//      Portio
0090: 6e 73 20 6f 66 20 74 68 69 73 20 66 69 6c 65 20  ns of this file 
00a0: 63 6f 70 79 72 69 67 68 74 20 28 63 29 20 4d 69  copyright (c) Mi
00b0: 63 72 6f 73 6f 66 74 20 43 6f 72 70 6f 72 61 74  crosoft Corporat
00c0: 69 6f 6e 0d 0a 2f 2f 20 20 20 20 20 20 61 6e 64  ion..//      and
00d0: 20 61 72 65 20 72 65 6c 65 61 73 65 64 20 75 6e   are released un
00e0: 64 65 72 20 74 68 65 20 4d 69 63 72 6f 73 6f 66  der the Microsof
00f0: 74 20 50 75 6c 69 63 20 4c 69 63 65 6e 73 65 2e  t Pulic License.
0100: 20 20 53 65 65 0d 0a 2f 2f 20 20 20 20 20 20 68    See..//      h
0110: 74 74 70 3a 2f 2f 61 72 63 68 69 76 65 2e 6d 73  ttp://archive.ms
0120: 64 6e 2e 6d 69 63 72 6f 73 6f 66 74 2e 63 6f 6d  dn.microsoft.com
0130: 2f 45 46 53 61 6d 70 6c 65 50 72 6f 76 69 64 65  /EFSampleProvide
0140: 72 2f 50 72 6f 6a 65 63 74 2f 4c 69 63 65 6e 73  r/Project/Licens
0150: 65 2e 61 73 70 78 0d 0a 2f 2f 20 20 20 20 20 20  e.aspx..//      
0160: 6f 72 20 4c 69 63 65 6e 73 65 2e 74 78 74 20 66  or License.txt f
0170: 6f 72 20 64 65 74 61 69 6c 73 2e 0d 0a 2f 2f 20  or details...// 
0180: 20 20 20 20 20 41 6c 6c 20 72 69 67 68 74 73 20       All rights 
0190: 72 65 73 65 72 76 65 64 2e 0d 0a 2f 2f 20 3c 2f  reserved...// </
01a0: 63 6f 70 79 72 69 67 68 74 3e 0d 0a 2f 2f 2d 2d  copyright>..//--
01b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01f0: 2d 2d 2d 0d 0a 0d 0a 6e 61 6d 65 73 70 61 63 65  ---....namespace
0200: 20 53 79 73 74 65 6d 2e 44 61 74 61 2e 53 51 4c   System.Data.SQL
0210: 69 74 65 0d 0a 7b 0d 0a 20 20 75 73 69 6e 67 20  ite..{..  using 
0220: 53 79 73 74 65 6d 3b 0d 0a 20 20 75 73 69 6e 67  System;..  using
0230: 20 53 79 73 74 65 6d 2e 43 6f 6c 6c 65 63 74 69   System.Collecti
0240: 6f 6e 73 2e 47 65 6e 65 72 69 63 3b 0d 0a 20 20  ons.Generic;..  
0250: 75 73 69 6e 67 20 53 79 73 74 65 6d 2e 44 69 61  using System.Dia
0260: 67 6e 6f 73 74 69 63 73 3b 0d 0a 20 20 75 73 69  gnostics;..  usi
0270: 6e 67 20 53 79 73 74 65 6d 2e 49 4f 3b 0d 0a 20  ng System.IO;.. 
0280: 20 75 73 69 6e 67 20 53 79 73 74 65 6d 2e 54 65   using System.Te
0290: 78 74 3b 0d 0a 20 20 75 73 69 6e 67 20 53 79 73  xt;..  using Sys
02a0: 74 65 6d 2e 44 61 74 61 2e 4d 65 74 61 64 61 74  tem.Data.Metadat
02b0: 61 2e 45 64 6d 3b 0d 0a 20 20 75 73 69 6e 67 20  a.Edm;..  using 
02c0: 53 79 73 74 65 6d 2e 44 61 74 61 2e 43 6f 6d 6d  System.Data.Comm
02d0: 6f 6e 2e 43 6f 6d 6d 61 6e 64 54 72 65 65 73 3b  on.CommandTrees;
02e0: 0d 0a 0d 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61  ....  /// <summa
02f0: 72 79 3e 0d 0a 20 20 2f 2f 2f 20 54 68 65 20 53  ry>..  /// The S
0300: 79 6d 62 6f 6c 50 61 69 72 20 65 78 69 73 74 73  ymbolPair exists
0310: 20 74 6f 20 73 6f 6c 76 65 20 74 68 65 20 72 65   to solve the re
0320: 63 6f 72 64 20 66 6c 61 74 74 65 6e 69 6e 67 20  cord flattening 
0330: 70 72 6f 62 6c 65 6d 2e 0d 0a 20 20 2f 2f 2f 20  problem...  /// 
0340: 3c 73 65 65 20 63 72 65 66 3d 22 53 71 6c 47 65  <see cref="SqlGe
0350: 6e 65 72 61 74 6f 72 2e 56 69 73 69 74 28 44 62  nerator.Visit(Db
0360: 50 72 6f 70 65 72 74 79 45 78 70 72 65 73 73 69  PropertyExpressi
0370: 6f 6e 29 22 2f 3e 0d 0a 20 20 2f 2f 2f 20 43 6f  on)"/>..  /// Co
0380: 6e 73 69 64 65 72 20 61 20 70 72 6f 70 65 72 74  nsider a propert
0390: 79 20 65 78 70 72 65 73 73 69 6f 6e 20 44 28 76  y expression D(v
03a0: 2c 20 22 6a 33 2e 6a 32 2e 6a 31 2e 61 2e 78 22  , "j3.j2.j1.a.x"
03b0: 29 0d 0a 20 20 2f 2f 2f 20 77 68 65 72 65 20 76  )..  /// where v
03c0: 20 69 73 20 61 20 56 61 72 52 65 66 2c 20 6a 31   is a VarRef, j1
03d0: 2c 20 6a 32 2c 20 6a 33 20 61 72 65 20 6a 6f 69  , j2, j3 are joi
03e0: 6e 73 2c 20 61 20 69 73 20 61 6e 20 65 78 74 65  ns, a is an exte
03f0: 6e 74 20 61 6e 64 20 78 20 69 73 20 61 20 63 6f  nt and x is a co
0400: 6c 75 6d 6e 73 2e 0d 0a 20 20 2f 2f 2f 20 54 68  lumns...  /// Th
0410: 69 73 20 68 61 73 20 74 6f 20 62 65 20 74 72 61  is has to be tra
0420: 6e 73 6c 61 74 65 64 20 65 76 65 6e 74 75 61 6c  nslated eventual
0430: 6c 79 20 69 6e 74 6f 20 7b 6a 27 7d 2e 7b 78 27  ly into {j'}.{x'
0440: 7d 0d 0a 20 20 2f 2f 2f 20 0d 0a 20 20 2f 2f 2f  }..  /// ..  ///
0450: 20 54 68 65 20 73 6f 75 72 63 65 20 66 69 65 6c   The source fiel
0460: 64 20 72 65 70 72 65 73 65 6e 74 73 20 74 68 65  d represents the
0470: 20 6f 75 74 65 72 6d 6f 73 74 20 53 71 6c 53 74   outermost SqlSt
0480: 61 74 65 6d 65 6e 74 20 72 65 70 72 65 73 65 6e  atement represen
0490: 74 69 6e 67 20 61 20 6a 6f 69 6e 0d 0a 20 20 2f  ting a join..  /
04a0: 2f 2f 20 65 78 70 72 65 73 73 69 6f 6e 20 28 73  // expression (s
04b0: 61 79 20 6a 32 29 20 2d 20 74 68 69 73 20 69 73  ay j2) - this is
04c0: 20 61 6c 77 61 79 73 20 61 20 4a 6f 69 6e 20 73   always a Join s
04d0: 79 6d 62 6f 6c 2e 0d 0a 20 20 2f 2f 2f 20 0d 0a  ymbol...  /// ..
04e0: 20 20 2f 2f 2f 20 54 68 65 20 63 6f 6c 75 6d 6e    /// The column
04f0: 20 66 69 65 6c 64 20 6b 65 65 70 73 20 6d 6f 76   field keeps mov
0500: 69 6e 67 20 66 72 6f 6d 20 6f 6e 65 20 6a 6f 69  ing from one joi
0510: 6e 20 73 79 6d 62 6f 6c 20 74 6f 20 74 68 65 20  n symbol to the 
0520: 6e 65 78 74 2c 20 75 6e 74 69 6c 20 69 74 0d 0a  next, until it..
0530: 20 20 2f 2f 2f 20 73 74 6f 70 73 20 61 74 20 61    /// stops at a
0540: 20 6e 6f 6e 2d 6a 6f 69 6e 20 73 79 6d 62 6f 6c   non-join symbol
0550: 2e 0d 0a 20 20 2f 2f 2f 20 0d 0a 20 20 2f 2f 2f  ...  /// ..  ///
0560: 20 54 68 69 73 20 69 73 20 72 65 74 75 72 6e 65   This is returne
0570: 64 20 62 79 20 3c 73 65 65 20 63 72 65 66 3d 22  d by <see cref="
0580: 53 71 6c 47 65 6e 65 72 61 74 6f 72 2e 56 69 73  SqlGenerator.Vis
0590: 69 74 28 44 62 50 72 6f 70 65 72 74 79 45 78 70  it(DbPropertyExp
05a0: 72 65 73 73 69 6f 6e 29 22 2f 3e 2c 0d 0a 20 20  ression)"/>,..  
05b0: 2f 2f 2f 20 62 75 74 20 6e 65 76 65 72 20 6d 61  /// but never ma
05c0: 6b 65 73 20 69 74 20 69 6e 74 6f 20 61 20 53 71  kes it into a Sq
05d0: 6c 42 75 69 6c 64 65 72 2e 0d 0a 20 20 2f 2f 2f  lBuilder...  ///
05e0: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 63   </summary>..  c
05f0: 6c 61 73 73 20 53 79 6d 62 6f 6c 50 61 69 72 20  lass SymbolPair 
0600: 3a 20 49 53 71 6c 46 72 61 67 6d 65 6e 74 0d 0a  : ISqlFragment..
0610: 20 20 7b 0d 0a 20 20 20 20 70 75 62 6c 69 63 20    {..    public 
0620: 53 79 6d 62 6f 6c 20 53 6f 75 72 63 65 3b 0d 0a  Symbol Source;..
0630: 20 20 20 20 70 75 62 6c 69 63 20 53 79 6d 62 6f      public Symbo
0640: 6c 20 43 6f 6c 75 6d 6e 3b 0d 0a 0d 0a 20 20 20  l Column;....   
0650: 20 70 75 62 6c 69 63 20 53 79 6d 62 6f 6c 50 61   public SymbolPa
0660: 69 72 28 53 79 6d 62 6f 6c 20 73 6f 75 72 63 65  ir(Symbol source
0670: 2c 20 53 79 6d 62 6f 6c 20 63 6f 6c 75 6d 6e 29  , Symbol column)
0680: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 74  ..    {..      t
0690: 68 69 73 2e 53 6f 75 72 63 65 20 3d 20 73 6f 75  his.Source = sou
06a0: 72 63 65 3b 0d 0a 20 20 20 20 20 20 74 68 69 73  rce;..      this
06b0: 2e 43 6f 6c 75 6d 6e 20 3d 20 63 6f 6c 75 6d 6e  .Column = column
06c0: 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20  ;..    }....    
06d0: 23 72 65 67 69 6f 6e 20 49 53 71 6c 46 72 61 67  #region ISqlFrag
06e0: 6d 65 6e 74 20 4d 65 6d 62 65 72 73 0d 0a 0d 0a  ment Members....
06f0: 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20      public void 
0700: 57 72 69 74 65 53 71 6c 28 53 71 6c 57 72 69 74  WriteSql(SqlWrit
0710: 65 72 20 77 72 69 74 65 72 2c 20 53 71 6c 47 65  er writer, SqlGe
0720: 6e 65 72 61 74 6f 72 20 73 71 6c 47 65 6e 65 72  nerator sqlGener
0730: 61 74 6f 72 29 0d 0a 20 20 20 20 7b 0d 0a 20 20  ator)..    {..  
0740: 20 20 20 20 2f 2f 20 53 79 6d 62 6f 6c 20 70 61      // Symbol pa
0750: 69 72 20 73 68 6f 75 6c 64 20 6e 65 76 65 72 20  ir should never 
0760: 62 65 20 70 61 72 74 20 6f 66 20 61 20 53 71 6c  be part of a Sql
0770: 42 75 69 6c 64 65 72 2e 0d 0a 20 20 20 20 20 20  Builder...      
0780: 44 65 62 75 67 2e 41 73 73 65 72 74 28 66 61 6c  Debug.Assert(fal
0790: 73 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20  se);..    }.... 
07a0: 20 20 20 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 20     #endregion.. 
07b0: 20 7d 0d 0a 7d 0d 0a                              }..}..