Skip to content

Constructor syntax cannot generate code #210

Description

@PhenX
using System.ComponentModel.DataAnnotations;
using EntityFrameworkCore.Projectables;

namespace VisualQueryBuilder.Projections;

public class ModelIntermediateProjection 
{
    public string Libelle { get; set; }
    public string NumeroDossier { get; set; }
    public decimal TotalHt { get; set; }
    public decimal TotalTtc { get; set; }
    public decimal TotalTva { get; set; }
    public decimal TotalParticipation { get; set; }
    public decimal TotalPrisEnCharge { get; set; }
    public string TypeValue { get; set; }
    public string TypeDisplay { get; set; }
    public bool IsForfaitValue { get; set; }
    public string IsForfaitDisplay { get; set; }
    
    [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)]
    public static ModelIntermediateProjection Create(Cdd cdd) => new()
    {
        Libelle = cdd.Libelle,
        NumeroDossier = cdd.Dossier?.Numero,
        TotalHt = cdd.TotalHt,
        TotalTtc = cdd.TotalTtc,
        TotalTva = cdd.TotalTva,
        TotalParticipation = cdd.TotalParticipation(cdd),
        TotalPrisEnCharge = cdd.TotalHt - cdd.TotalParticipation(cdd),
        TypeValue = cdd.Type?.ToString(),
        TypeDisplay = cdd.Type?.ToDisplayName(),
        IsForfaitValue = cdd.IsForfait,
        IsForfaitDisplay = cdd.IsForfait ? "Yes" : "No",
    };
}

It seems to crash on the null coalesce operators and ternary

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions