Automapping PopulateWithNonDefaultValues and System.Uri


im using PopulateWithNonDefaultValues to populated my dataobject with my request properties.
They are having System.Uri as datatype but when populated they are populated as a string with “” around it.

Which means images are saved as


instead of

Please provide example code showing the issue.

DTO property is the following

     IsRequired = false,
     Description = "The service image")]
    public Uri ImageUrl { get; set; }

And in service i do this

    var service = Db.Single<ServiceModel.Db.Service>(
          .Where(s => s.CompanyId == request.CompanyId && s.Id == request.Id));

        //Copy values

now its saved as ""
if i add this line after

service.ImageUrl = request.ImageUrl;

it works without “” around the image

Should be resolved from this commit.

This change is available from v5.4.1 that’s now available on MyGet.

i still have the same problem once trying to save it to db.

In my ORMLite T4 template i have set the column to be type of URI (is varchar(max) in db)


But when it’s saved it still is saved as “” around the filename



is populated correctly but its not saved correctly

Regards Kristian

RDBMS’s don’t have a Uri column type you should ideally be using a string on your Data models as otherwise it has to treat it as a complex type instead of a scalar string value.

Anyway I’ve added a test showing it’s saving/retrieving without issue in this commit, please include a stand-alone unit test I can run locally that shows the issue.

it’s still are saved as " " around the filename in the database but when retrieving it back using ormlite it’s converted back to URI successfully without " " around it.
So it’s hard to create a unit test as you can only see the result i the DB and not when retrieving it back from DB using ormlite

That’s because you’re using Uri instead of string in your data model as per my previous comment.