I have a Linq-to-SQL entity that I will be serializing and returning as JSON over a webservice call.
There is one property on that entity that I would like not to be serialized. For this, there is generally the [ScriptIgnore]
attribute, which works exactly the way I want if I manually add that to the designer.cs file.
Now, since the designer file is automatically generated, I would prefer not having to manually edit it, as any changes could easily be overwritten. My question is thus: is there any way to annotate the property so that it is excluded upon serialization, directly in the DBML editor?
If the answer is no; are there any solutions to this that are neater than manually setting the property to null
before serializing it, or returning an anonymous type identical except for that one property? In MVC.NET, is there any way to pass parameters to the JSON()
method to modify its behavior, perchance?
My apologies if this has been asked before - I'd expect it to be a common question, but I couldn't find anyone like it.