Map string to guid with Dapper

前端 未结 6 543
广开言路
广开言路 2020-12-30 03:48

I\'m using Dapper to hammer out some load testing tools that need to access a PostgreSQL database. This particular version of PostgreSQL does not support GUIDs natively, so

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 04:41

    I hope that can help.

    I didn't have to use alias in my query. What I did:

    public abstract class Entity
    {
        protected Entity()
        {
            Id = Guid.NewGuid().ToString();
        }
    
        public string Id
        {
            get; set; 
        }
    }
    

    And in your table the type as varchar

提交回复
热议问题