当前位置:网站首页>WCF: expose unset read-only DataMember property- WCF: Exposing readonly DataMember properties without set?
WCF: expose unset read-only DataMember property- WCF: Exposing readonly DataMember properties without set?
2022-07-05 01:29:00 【Zafo】
problem :
I have a server side class which I make available on the client side through a [DataContract]. I have a server-side class , Can pass [DataContract] Use on client .This class has a readonly field which I'd like to make available through a property. This class has a read-only field , I want to provide this field through an attribute .However, I'm unable to do so because it doesn't seem that I'm allowed to add a [DataMember] property without having both get and set. however , I can't do this , Because it seems that I am not allowed to get and set Add if [DataMember] attribute .
So - is there a way to have a [DataMember] property without setter? therefore - Is there any way? No setter Of [DataMember] Attribute ?
[DataContract]class SomeClass{ private readonly int _id; public SomeClass() { .. } [DataMember] public int Id { get { return _id; } } [DataMember] public string SomeString { get; set; }}Or will the solution be use the [DataMember] as the field - (like eg shown here )? Or use it in the solution [ Data member ] As field - ( For example, image display ad locum )?Tried doing this too, but it doesn't seem to care the field is readonly..? I have also tried to do this , But it doesn't seem to care that the field is read-only .
Edit : Is the only way to make a readonly property by hacking it like this? edit : Is this the only way to make it a read-only property ?(no - I don't want to do this...)( no - I don't want to do that ...)
[DataMember]public int Id{ get { return _id; } private set { /* NOOP */ }}Solution :
Reference resources : https://stackoom.com/en/question/7rRd边栏推荐
- PHP Basics - detailed explanation of DES encryption and decryption in PHP
- Can financial products be redeemed in advance?
- Exploration and practice of integration of streaming and wholesale in jd.com
- Hedhat firewall
- 107. Some details of SAP ui5 overflow toolbar container control and resize event processing
- PHP Joseph Ring problem
- Es uses collapsebuilder to de duplicate and return only a certain field
- 【海浪建模3】三维随机真实海浪建模以及海浪发电机建模matlab仿真
- Common bit operation skills of C speech
- Blue Bridge Cup Square filling (DFS backtracking)
猜你喜欢

Wechat applet: Xingxiu UI v1.5 WordPress system information resources blog download applet wechat QQ dual end source code support WordPress secondary classification loading animation optimization

微信小程序:全网独家小程序版本独立微信社群人脉

微信小程序:独立后台带分销功能月老办事处交友盲盒

Game 280 of leetcode week

Hedhat firewall

Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue

Yyds dry goods inventory kubernetes management business configuration methods? (08)

Four pits in reentrantlock!

Implementation steps of master detail detail layout mode of SAP ui5 application

Single step debugging of master data reading of SAP commerce cloud products
随机推荐
【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
Wechat applet: wechat applet source code download new community system optimized version support agent member system function super high income
Using openpyxl module to write the binary list into excel file
[development of large e-commerce projects] performance pressure test - Performance Monitoring - heap memory and garbage collection -39
Hand drawn video website
Robley's global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
phpstrom设置函数注释说明
Discrete mathematics: Main Normal Form (main disjunctive normal form, main conjunctive normal form)
Es uses collapsebuilder to de duplicate and return only a certain field
Global and Chinese markets for industrial X-ray testing equipment 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of nutrient analyzer 2022-2028: Research Report on technology, participants, trends, market size and share
Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
Playwright recording
整理混乱的头文件,我用include what you use
微信小程序:全网独家小程序版本独立微信社群人脉
Kibana installation and configuration
Wechat applet: Xingxiu UI v1.5 WordPress system information resources blog download applet wechat QQ dual end source code support WordPress secondary classification loading animation optimization
【CTF】AWDP总结(Web)
[microprocessor] VHDL development of microprocessor based on FPGA
I was beaten by the interviewer because I didn't understand the sorting