How can I open TimeSpan through the WCF data service?

I am creating a WCF data service for my meeting database.

I keep the DateTime destination with a duration of type TimeSpan. When I try to access my data service, I get the following error:

"The server encountered an error while processing the request. Exception message:" The "Duration" property in the "Destination" type is of the "Time" type, which is not a supported primitive type. ".."

Any idea how I can imagine the length of time and make it available through my WCF data service?

+4
source share
2 answers

I suggest exposing a new property for serialization (labeled DataMemberAttribute ) that uses the Ticks property of your original time.

For instance:

 [DataMember("TheTimeSpanTicks")] public long TheTimeSpanTicks { get { return TheTimeSpan.Ticks; } set { TheTimeSpan = new TimeSpan(value); } } 

I'm not sure what the requirements for accessing serialization will be. Perhaps you could use protected instead of public .

+6
source

Can you specify the duration as Ticks, TotalSeconds or some other primitive that can be calculated for hours, minutes, etc.?

0
source

Source: https://habr.com/ru/post/1347172/


All Articles