public virtual string ToWorkshop(OutputLanguage language)
        {
            AddMissingParameters();

            List <string> parameters = AdditionalParameters().ToList();

            parameters.AddRange(ParameterValues.Select(p => p.ToWorkshop(language)));

            string result = Extras.Indent(Indent, true); // TODO: option for spaces or tab output.

            if (!ElementList.IsValue && Disabled)
            {
                result += LanguageInfo.Translate(language, "disabled") + " ";
            }
            result += LanguageInfo.Translate(language, Name);
            if (parameters.Count != 0)
            {
                result += "(" + string.Join(", ", parameters) + ")";
            }
            else if (AlwaysShowParentheses)
            {
                result += "()";
            }
            if (!ElementList.IsValue)
            {
                result += ";";
            }
            return(result);
        }
예제 #2
0
        protected override object Clone([NotNull] object model)
        {
            var clone = (ProductTypeModel)model;

            clone.ParameterValues = ParameterValues.Select(p => (FieldModel)p.Clone()).ToList();

            return(clone);
        }
        public virtual string ToWorkshop(OutputLanguage language, ToWorkshopContext context)
        {
            // Get the parameters
            AddMissingParameters();
            List <string> parameters = AdditionalParameters().ToList();

            parameters.AddRange(ParameterValues.Select(p => p.ToWorkshop(language, ToWorkshopContext.NestedValue)));

            string result = Extras.Indent(Indent, true); // TODO: option for spaces or tab output.

            // Add a comment and newline
            if (Comment != null)
            {
                result += $"\"{Comment}\"\n" + Extras.Indent(Indent, true);
            }

            // Add the disabled tag if the element is disabled.
            if (!ElementList.IsValue && Disabled)
            {
                result += LanguageInfo.Translate(language, "disabled") + " ";
            }

            // Add the name of the element.
            result += LanguageInfo.Translate(language, Name);

            // Add the parameters.
            if (parameters.Count != 0)
            {
                result += "(" + string.Join(", ", parameters) + ")";
            }
            else if (AlwaysShowParentheses)
            {
                result += "()";
            }

            // Add the ; if the element is an action.
            if (!ElementList.IsValue)
            {
                result += ";";
            }
            return(result);
        }
        internal static (string, IEnumerable <SqlParameter>) ToParametrizedSql <TEntity>(this IQueryable <TEntity> query) where TEntity : class
        {
            var queryCompiler           = (QueryCompiler)QueryCompilerField.GetValue(query.Provider);
            var modelGenerator          = (QueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler);
            var parameterValues         = new SimpleParameterValues();
            var diagnosticsLogger       = new DiagnosticsLogger <DbLoggerCategory.Query>(new LoggerFactory(), null, new DiagnosticListener("Temp"));
            var parameterExpression     = modelGenerator.ExtractParameters(diagnosticsLogger, query.Expression, parameterValues);
            var queryModel              = modelGenerator.ParseQuery(parameterExpression);
            var database                = (IDatabase)DataBaseField.GetValue(queryCompiler);
            var databaseDependencies    = (DatabaseDependencies)DatabaseDependenciesField.GetValue(database);
            var queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false);
            var modelVisitor            = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor();

            modelVisitor.CreateQueryExecutor <TEntity>(queryModel);
            //modelVisitor.CreateAsyncQueryExecutor<TEntity>(queryModel);
            // CreateAsync not used, throws: Message: System.ArgumentException : Expression of type 'System.Collections.Generic.IEnumerable`1[EFCore.BulkExtensions.Tests.Item]'
            // cannot be used for return type 'System.Collections.Generic.IAsyncEnumerable`1[EFCore.BulkExtensions.Tests.Item]'

            string sql = modelVisitor.Queries.First().ToString();

            return(sql, parameterValues.ParameterValues.Select(x => new SqlParameter(x.Key, x.Value)));
        }
 public void UpdateParameters()
 {
     Model.ParameterValues = string.Join("#", ParameterValues.Select(x => x.Name + "=" + x.Value));
 }
 public override string ToString() => Function.Name.ToString() + (ParameterValues.Length == 0 ? "" : "(" + string.Join(", ", ParameterValues.Select(v => v.ToString())) + ")");
예제 #7
0
 protected override void OnSave(string value)
 {
     base.OnSave(value);
     Model.Parameter = string.Join("#", ParameterValues.Select(x => x.Name + "=" + x.Value));
 }
예제 #8
0
 public override string ToString()
 {
     return(string.Join(", ", ParameterValues.Select(p => p.ParameterValue.ToString())));
 }
 public IWorkshopTree Parse(ActionSet actionSet, IWorkshopTree[] parameters) => new V_String(String, ParameterValues.Select(pv => (Element)pv.Parse(actionSet, parameters)).ToArray());
예제 #10
0
 /// <summary>
 /// Objects to string.
 /// </summary>
 /// <returns>String objects.</returns>
 public override string ToString()
 {
     return(string.Format("QueryName={0} SqlQueryId={1} QueryCodeColumn={2}", QueryName, SqlQueryId, QueryCodeColumn)
            + string.Join(" ", ParameterValues.Select(pv => pv.ToString())));
 }
 /// <summary>
 /// Objects to string.
 /// </summary>
 /// <returns>String objects.</returns>
 public override string ToString()
 {
     return(string.Format("QueryFileName={0} QueryName={1}", QueryFileName, QueryName)
            + string.Join(" ", ParameterValues.Select(pv => pv.ToString())));
 }