Exemple #1
0
        public async Task <User> Find(UserId aggregateId)
        {
            var query = $@"
                SELECT
                    id as Id,
                    display_name as Name,
                    normalized_name as NormalizedName
                FROM laundry.users
                WHERE id = @id";

            var guid = aggregateId.GetGuid();

            using (var connection = new NpgsqlConnection(_options.ConnectionString))
            {
                var dataModel = await connection.QuerySingleOrDefaultAsync <UserDataModel>(query, new { id = aggregateId.GetGuid() });

                if (dataModel == null)
                {
                    return(null);
                }

                var aggregate = UserMapper.From(dataModel);

                return(aggregate);
            }
        }