Ejemplo n.º 1
0
        /// <summary>
        /// Conver a window definition to an string list
        /// </summary>
        static IReadOnlyList <string> WindowDefToStrList(ISqlWindow window, IEnumerable <NamedWindow> others, SqlExprParams pars)
        {
            var           current  = window.Current;
            var           previous = window.Previous;
            List <string> retItems = new List <string>();;

            if (previous != null)
            {
                var existingWindow = others.Where(x => x.Window == previous).FirstOrDefault();
                //The previous window is an existing one:
                if (existingWindow != null)
                {
                    retItems.Add(existingWindow.Name);
                }
                else
                {
                    retItems.AddRange(WindowDefToStrList(window.Previous, others, pars));
                }
            }
            if (current.PartitionBy?.Any() == true)
            {
                retItems.Add(PartitionByStr(current.PartitionBy, pars));
            }
            if (current.OrderBy?.Any() == true)
            {
                retItems.Add(OrderByStr(current.OrderBy, pars));
            }
            if (current.Frame != null)
            {
                retItems.Add(WindowFrameClauseStr(current.Frame));
            }
            return(retItems);
        }
Ejemplo n.º 2
0
 public SqlWindowBuilder(WindowClauses input, ISqlWindow previous, SqlWindowClause current)
 {
     Input    = input;
     Previous = previous;
     Current  = current;
 }
Ejemplo n.º 3
0
 public static string WindowToSql(ISqlWindow window) => throw new SqlFunctionException();
Ejemplo n.º 4
0
 public NamedWindow(string name, ISqlWindow window)
 {
     Name   = name;
     Window = window;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Convert a window definition to string
 /// </summary>
 static string WindowDefToStr(ISqlWindow window, IEnumerable <NamedWindow> others, SqlExprParams pars)
 {
     return(string.Join(Environment.NewLine, WindowDefToStrList(window, others, pars)));
 }
Ejemplo n.º 6
0
 public static T Over <T>(T acum, ISqlWindow over) => throw new SqlFunctionException();