开发者

Does GenerateScriptType support NonSerialized?

开发者 https://www.devze.com 2023-01-01 17:20 出处:网络
I have an object that\'s used both on the client and server side. GenerateScriptType(typeof(MyClass)) However, there are some fields that I don\'t need on the client, so my question is there any wa

I have an object that's used both on the client and server side.

GenerateScriptType(typeof(MyClass))

However, there are some fields that I don't need on the client, so my question is there any way to prevent those fields being serialized? (For example, Field2 and Field3 in MyClass)

I tried marking the fields with [NonSerialized] but they still get serialized...

开发者_StackOverflow
    public class MyClass
    {
        public string Field1;
        public string Field2
        {
            get;
            set;
        }
        private string _field3;
        public string Field3
        {
            get
            {
                return _field3 ?? (_field3 = "lala");
            }
        }
    }

Regards,


Try adding the ScriptIgnore attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消