Esempio n. 1
0
        public ICompiled Compile()
        {
            SetType(PartType.Compiled);

            var state = new CompileState(PersistenceProvider.SupportedTypeMappings, PersistenceProvider.Translator);

            Query[] parts = GetParts();
            ForEach(parts, state.Text, "\r\n", item => item?.Compile(state));
            CompiledQuery = new CompiledQuery(state, parts.Last(item => item.Last).AsResults ?? new AsResult[0]);

            if (CompiledQuery.Errors.Count > 0)
            {
                throw new QueryException(CompiledQuery);
            }

            return(this);
        }
Esempio n. 2
0
 public QueryException(CompiledQuery query) : base($"There were errors during compilation of the query. Please check the exception details.")
 {
     QueryText       = query.QueryText;
     QueryParameters = query.Parameters.Select(item => $"Parameter: Name = {item.Name}, Type = {item.Type?.FullName ?? "NULL"}").ToArray();
     ErrorMessages   = query.Errors.Select(item => $"Error: {item}").ToArray();
 }