Force tablename on column in each SQL statement

Thread is closed for posting
1 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    32 posts
    Member since:
    Jan 2013

    Posted 05 Dec 2017 Link to this post


    I need calculated column on PostgreSql backend. It's work in almost case. 

    I define my model like this:

    public class MyEntity{
       public int IdMyEntity;
       public string Display;
       public int CalculatedColumn;
    MappingConfiguration<MyEntity> configuration = new MappingConfiguration<MyEntity>();
    configuration.MapType(x => new {
                    IdMyEntity = x.IdMyEntity,
                    Display = x.Display,
                    CalculatedColumn = x.CalculatedColumn
    configuration.HasProperty(x => x.IdMyEntity).ToColumn("idmyentity").WithDataAccessKind(DataAccessKind.ReadWrite).IsIdentity(KeyGenerator.Autoinc).IsNotNullable();
    configuration.HasProperty(x => x.Display).ToColumn("display").WithDataAccessKind(DataAccessKind.ReadWrite).IsNullable();          
    configuration.HasProperty(x => x.CalculatedColumn).ToColumn("calculatedcolumn").WithDataAccessKind(DataAccessKind.ReadOnly).IsNullable();

    If I use this Linq

    List<MyEntity> list = this.MyDatabase.MyEntitys;

    ORM run this SQL statement : SELECT a."idmyentity" COL1, a."display" COL2, a."calculatedcolumn" COL3 FROM "mytable" a;

    And that's work.


    But if I use this Linq

    MyEntity oneEntity = this.MyDatabase.MyEntitys.Where(x => x.IdMyEntity == 1);

    ORM run this SQL statement : SELECT "idmyentity", "display", "calculatedcolumn" FROM "mytable" WHERE "idmyentity" = :p0;

    And I have an error because Postgresql must have table name in prefix of column.

    Have you a solution to add table name (or alias) in each SQL statement ?

    Thanks in advance

Back to Top