11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

amrameshreddy.blog.com340 CHAPTER 11 ■ WORKING WITH DATAramrameshreddy.blog.com}[DataMember]internal decimal AvgVol;[DataMember]internal double MarketCap;[DataMember]internal decimal PERatio;[DataMember]internal decimal EPS;[DataMember]internal decimal FiftyTwoWeekHigh;[DataMember]internal decimal FiftyTwoWeekLow;Data Contract NamesSometimes even though a consumer and a service might not share the same type, they canstill pass data between each other as long as the data contracts are equivalent on both sides.This equivalence is based on a combination of the data contract and data member names.These data contract and data member names follow a few simple rules that you can use tomap the different types in situations where they differ on either end. These data contract andmember rules are as follows:• The “fully qualified” data contract name consists of both the namespace and a name.• Data members have only names (no namespaces).• Namespaces, data contract, and member names are case-sensitive.The default namespace for a data contract is in the form of a URI, which can be eitherabsolute or relative. By default, the namespace is the same as the CLR namespace for that typeand maps to http://schemas.datacontract.org/2004/07/Clr.Namespace with the correct CLRnamespace. If required, you can change the default namespace in two ways. First, you canchange the Namespace property of the [DataContract] attribute. Second, you can apply the[ContractNamespace] attribute to the relevant module or assembly.A data contract’s default name is the name for that type. You can use the Name property ofthe [DataContract] attribute to override the default name. Similar to the data contract, thedefault name for a data member is the name of that member (field or property). You can usethe Name property on the [DataMember] attribute to override that default. Listing 11-2 shows anupdated version of the data contract from Listing 11-1 with the default names overridden.ramrameshreddyramrameshreddy

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!