Пример #1
0
    public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
    {
        var userQuery = Database.Query <UserQueryEntity>().SingleEx(a => a.Guid == Guid.Parse((suffix.TryBefore("\n") ?? suffix).Trim()));

        using (CurrentEntityConverter.SetCurrentEntity(context.GetEntity()))
        {
            var         request = UserQueryLogic.ToQueryRequest(userQuery);
            ResultTable result  = QueryLogic.Queries.ExecuteQuery(request);
            return(result.ToDataTable());
        }
    }
Пример #2
0
    public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext ctx)
    {
        MethodInfo mi = GetMethod(ctx.Template, suffix);

        object?result;

        try
        {
            result = mi.Invoke(ctx.Model, null);
        }
        catch (TargetInvocationException e)
        {
            e.InnerException !.PreserveStackTrace();

            throw e.InnerException !;
        }

        if (!(result is Data.DataTable dt))
        {
            throw new InvalidOperationException($"Method '{suffix}' on '{ctx.Model!.GetType().Name}' did not return a DataTable");
        }

        return(dt);
    }
Пример #3
0
 public Data.DataTable GetDataTable(string suffix, WordTemplateLogic.WordContext context)
 {
     return(GetDataTable(suffix, context.GetEntity()));
 }