Last post May 22, 2015 06:52 AM by hambi
May 21, 2015 02:50 PM|hambi|LINK
Hi. I have created a Linq to SQL datacontext. In one table I have a string field. However, the data in that field is a custom class (myString).
I'd like to know what is the cleanest and most efficient way to have the datacontext with the field as type myString rather than string. I realise that the datacontext defines classes as partial classes. Thus I can add methods to the datacontext but that
alone still means the field is a string. I would prefer not to try deriving a class. What are the options and any recommendation for the best option.
myString has its own methods, validation and function.
May 21, 2015 05:08 PM|Mikesdotnetting|LINK
Linq to SQL is pretty much deprecated in favour of Entity Framework. However, if you want to know more about custom type mapping, this should help: https://msdn.microsoft.com/en-us/library/cc716764(v=vs.110).aspx
May 22, 2015 06:52 AM|hambi|LINK
Thanks. I didn't realise you could just change the datatype in the O/R designer to a custom type. Magic.
I haven't used Entity Framework and this website has to be finished quickly and has been a very long journey. I'm therefore reluctant to learn a new framework but I'm in two minds. The site I am working on has a complex model so either EF will either make it
much easier or more complicate and not knowing much about EF I'm not sure which,
I really appreciate the help on the datatype question. Thanks