Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. Is it posible to add ScriptIgnore attribute on foreign key property in linq to sql class automatically, not by hands, because every time i regenerate this class, attributes are removed.
?
Posted

The problem is that such class is generated automatically by the environment, so every time you change the data layer your changes are cleaned and a new code generated...
Your only option is to handle it manually, by taking advantage of the fact that the generated code only affect the .designer.cs file and the class generated is partial...
 
Share this answer
 
I wrote an extension method, where i set the value to null, instead using script ingore.
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 8-Feb-15 8:41am    
And how that answers your question? Can you explain it in details?
Arlert 8-Feb-15 16:03pm    
i am doing a restful web service. i need to return user data in json. as i am using linq to sql class, i return auto-generated model. token data is also returning with user's one (because tables are related). i made an extension method, and when i need to return only user's data without token or etc, i call this method, where i set token as null. not a good practice, but for test is good.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900