How to map a string to Uri type using the Entity Framework?


My database contains a column of type string, that represents a URL. I'm now wondering how its possible to map this string to a Uri object using the Entity Framework.

Any ideas?


Use a partial class, w/ a custom property:

    public partial class MyClass
        public Uri MyUri
                { return new Uri(StringUriPropertyFromDB); }

You can make the string property private in the EF designer, if you want. Note you can't use custom properties like this in LINQ to entities, though.

You do realize that format has nothing to do with how SQL Server stores datetime, right?

You can use set dateformat for each session. There is no setting for database only.

If you use parameters for data insert or update or where filtering you won't have any problems with that.

This video can help you solving your question :)
By: admin