問題タブ [datacontracts]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
1022 参照

c# - リストを繰り返す

データテーブルを反復処理し、各値を datacontract リスト内の特定のプロパティに割り当てるのに苦労しています。

したがって、次の DataContract があります。

私のサービスでは、DispatchDetails のリストを返したいのですが、問題は各プロパティに値を割り当てることです。

私が達成しようとしていることを実証するために、最新の危険なコード行を追加しました。私はいくつかの方法を試しましたが、現時点では木を通して木を見るのに苦労しているようです:)

アドバイスをいただきありがとうございます。

敬具、クリスチャン

0 投票する
1 に答える
34 参照

datacontracts - データ契約のプロパティからプロパティ名を取得する方法

私はデータコントラクトを持っており、その中で、以下のコードで説明されているようにプロパティの名前を取得したいと思います。

今、私は値を次のように渡します

ここで、ハードコードされた「PhoneNumber」の代わりにプロパティ名を取得するために渡す必要があります

どうすればこれを達成できますか?

0 投票する
2 に答える
865 参照

wcf - 単一のオブジェクトで 3 つのデータ コントラクトを継承する方法は?

3 つのデータ コントラクト オブジェクトを呼び出して、それを 1 つのオブジェクトに作成する方法は?

このようなデータ コントラクト クラスがあります。

次のような別のデータ コントラクト クラス

次のような別のデータ コントラクト クラス

今、同じメソッドで AddressId、EmailId、PhoneId を使用したいと考えています。

それはどのように可能ですか??

0 投票する
2 に答える
245 参照

azure - Shared DataContract ワーカー ロール / Web ロール

ワーカー ロールを使用して Web ロールにデータを提供し、Web ロールと [機密データを含む] データベースとの間の分離を維持する目的で、内部エンドポイントを介してワーカー ロールにリンクされた Azure Web ロールがあります。Worker ロールと Web ロールの両方によって参照される、必要なすべてのデータ コントラクトを含むクラス ライブラリ プロジェクトがあります。

開発環境では、すべて問題なく動作します。Azure にアップロードするとすぐに、ワーカー ロールの開始に失敗します。エラーメッセージは次のとおりです。

データ コントラクト クラス ライブラリ「ReadOnly_DC」を開くことができないようです。

ReadOnly_DC への参照はローカルにコピーするように設定されており、データ コントラクト クラス ライブラリに付随するすべての参照で「ローカルにコピー」を試みましたが、役に立ちませんでした。

どんな提案もありがたく受け取りました!

許す

0 投票する
2 に答える
572 参照

c# - データ アクセス レイヤーからデータ コントラクトに値を直接受け入れるのは正しいですか?

データ アクセス層のデータベースから取得した値を WCF 層のデータ コントラクトに割り当てる正しい方法について質問があります。

データベースからすべての学生のリストを取得し、それを学生データ コントラクトに割り当てる単純なシナリオを考えてみます。

私の学生データ契約は次のようになります。

私のデータ アクセス クラスには、List GetAllStudents() のようなメソッドがあります。

私の質問は、GetAllStudents() メソッドの実装に関するものです。以下のような表示でよろしいでしょうか。

  1. public List GetAllStudents() {

    }

データ コントラクトに値を割り当てる上記の方法は正しいですか、それとも、次のように、データ アクセス レイヤーでデータを受け入れてから、サービス コントラクト実装のデータ コントラクトに値を渡す学生ビジネス オブジェクト クラスを用意する必要があります。 :

  1. 次のような学生ビジネスオブジェクトクラスがあります。

    パブリック クラス StudentBO {

    }

次に、データ アクセス レイヤーで、データベースから取得した値を学生ビジネス オブジェクトのコレクションに次のように割り当てます。

学生ビジネス オブジェクトの値は、サービス コントラクト実装の学生データ コントラクトに割り当てられ、そこからネットワーク経由で送信されます。

上記の2つの方法のうち、正しい方法はどれですか?

0 投票する
1 に答える
867 参照

wcf - WCF : 親とは異なるデータメンバーの名前空間

提供された外部 API を実装する必要があります。この API は変更できません。この API の場合、SOAP メッセージが交換されます。そのうちの 1 つは障害例外を処理するものです。

asmx などの他のフレームワークでこれを実装できますが、WCF では成功しません。データ メンバーは、データ コントラクトと同じ名前空間を持っているようです。datamember の名前空間を追加する方法はありますか?

どうもありがとう

0 投票する
1 に答える
171 参照

c# - JSON がサブ配列で null を返すのはなぜですか?

入ってくる Json メッセージをシリアライズ (およびデシリアライズ) するのに苦労しました。1 つ目は、POSTMAN 経由で MVC レスト サービスに投稿する受信 Json です。JsonLint で検証しました。主な問題は、accounts と propertyValues の 2 つのサブ配列が null として渡されることです。serviceAddresses は profilePush の配列メンバーであり、その他のプロパティは設定されています。それらをすべて DataContracts にする前は、serviceAddresses に対して null 値を取得していました。ここで何が欠けていますか?

------------ 着信 JSON ------------------

--------手順に入る「プロファイル」はこんな感じです --------------

0 投票する
2 に答える
2683 参照

c# - Property of type List in DataContract class fails

I'm developing a WCF with two Classes as DataContracts. One of them is a Data Structure developed by myself which manages Objects as JSON one, it names JSON; the

I'm developing a WCF with two Classes as DataContracts. One of them is a Data Structure developed by myself which manages Objects as JSON one, it names JSON; the other is just a Customized Object that my WebService recieve, it names Emission. I have three methods; one is for create policies, other one retrieves a policy and the last one consults catalogs in a dynamical way using JSON class. My problem comes within an error message like this:

"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter ... The InnerException message was 'Error in line 1 position 823. Element ... contains data of the 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfanyType' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'ArrayOfanyType' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'.
Please see InnerException for more details."

I was looking for an answer then I noticed that the cause of my problem was a property in my JSON class which is a list of generic Objects. I need this property in my client to initialize the object I expect to recieve, so this list could contain strings or another List of Objects that's why I need this kind of item.

I've tried to use sort of KnownTypes with no success but I don't know if I'm doing something wrong

It is important to say that if I SET value property as internal everything goes fine even JSON class in client side although value property is never shown. Attach a shred of my code:

I hope you can really help me. Thanks in advice!


C++ function argument losing part of address

I got a really weird bug(?) on Win8x64 driver in C++, which crashes the system.

Background info: -- I did notice the driver crashes seemingly at random place of the codes, but didn't check why. - I'm making some changes in "funcD()", not related to the crash. - I compiled the binaries with debug, and noticed (now several time) that it crashes at the beginning of "funcB".

Problem: The issue is with the address of "arg2". The correct "arg2" address is there inside "funcA", which calls "funcB". But once inside "funcB", the address for "arg2" gets truncated.

e.g. arg2 = 0xffffe000'01ace148 while in "funcA", which then passes to calling "funcB". But inside "funcB", it becomes arg2 = 0x00000000'01ace148

I really have no idea how this can happen, so any suggestion welcomed! Don't think my changes in the downstream "funcD" could have caused this, yeah?

EDIT:

Both "typedefs" are pointer to some different structs.

Notice "funcA" doesn't do anything except calling "funcB" directly with the exact same arguments it receives. And both "funcA" and "funcB" have the same parameters (different return type tho), yet "funcA" has no problem receiving the arguments' addresses.

0 投票する
1 に答える
1151 参照

wcf - Web APIスタックでDataContractResolverを置き換えるには?

WCF を使用している場合、DataContractResolver を置き換えるにはさまざまな方法があります。私は Web Api で同じことをしたいと考えています。私が見つけた唯一の拡張ポイントはこれです:

(疑似コード)の行で何かを探しています: