AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 21.12.2013, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
Pawan's Ax blog: Using Data Contracts in X++ [AX 2012]
Источник: http://pawansaxblog.blogspot.com/201...x-ax-2012.html
==============



Microsoft Dynamics AX supports the use of .NET and X++ types as data contracts for service operation input and return parameters. This enables you to pass complex data types without having to explicitly implement XML serialization and deserialization. The data contract serialization and deserialization is handled by Windows Communication Foundation (WCF).
In order to serialize complex data types, we must define them as data contracts.
X++ Types
X++ provides support for data contract serialization through the following attributes.
·DataContractAttribute – This attribute is applied to an X++ class and specifies that the class can be used as a data contract (that it should be serialized).
·DataMemberAttribute – This attribute is applied to a parm method on an X++ data contract class and specifies that the data member should be serialized. The attribute can be applied to public and instance methods, as long as the method uses a get/set pattern that contains one optional parameter. The data type of the return type and the parameter should be the same. For example, [DataMemberAttribute] Int parmXX(int _x = x)
The X++ data contract attributes function just as the data contract attributes for .NET types.
The following X++ constructs can be used implicitly as data contracts and do not require markup with the data contract attributes:
·Primitive types such as str, int, int64, real, guid, utcdatetime, and date. Primitive types are shared between services on the same integration port and stored in a shared types .xsd file.
·Extended data types.
·Enumerations including X++ boolean.
·Collections in which all elements are the same type and all elements are of a type that is a valid data contract. This includes the Array class, which is part of Collections.
·Tables and views. All columns and array fields are exposed as a System.Data.Dataset.
.NET Types
Any .NET type that can be serialized by WCF can be used as a parameter or return type by a service in Microsoft Dynamics AX. By default, WCF uses the Data Contract Serializer to serialize and deserialize data.

To use .NET types as parameters or return types in X++, we must first create a .NET assembly that contains the .NET data contract classes that have been decorated with the data contract attributes. We then add this assembly as a reference in the AOT, and we can use the data contracts in X++ service operations.

When using the DataContractSerializer, WCF serializes DateTime values as Coordinated Universal Time (UTC). When you use DateTime values in a data contract, you must pass them as UTC values and convert to local time in the client that calls the service.





Источник: http://pawansaxblog.blogspot.com/201...x-ax-2012.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Pawan's Ax blog: Code to copy data from one table to another even though the tables are different provided the field names are same. in Ax2012 Blog bot DAX Blogs 0 09.12.2013 00:14
emeadaxsupport: AX 2012 R2 In-Place Upgrade – Sometimes during the Data Upgrade Checklist the Detect Update Scripts step does not prepare any scripts to run. Blog bot DAX Blogs 0 19.04.2013 20:13
DAX: Official Dynamics AX 2012 R2 Content (update) - Where is it, and how can you find out about updates? Blog bot DAX Blogs 0 03.12.2012 11:11
dynamicsaxtraining: Purchase Blog bot DAX Blogs 0 11.03.2012 05:25
dynamics-ax: Blog Spotlight: Dynamics AX 2012 Upgrade frustrations of Alex Blog bot DAX Blogs 0 28.06.2011 06:19

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 12:43.