問題タブ [automapper-3]

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 に答える
1253 参照

valueinjecter - 2014 年時点での Automapper と Value Injecter のパフォーマンスと柔軟性

Automapper と Value Injecter のうち、どちらが最速で、どちらが柔軟ですか? 2014年現在(現在)過去の評価ではありません

0 投票する
0 に答える
598 参照

c# - Automapper 複合オブジェクト マッピングの NullReference 例外

私は次のクラスを持っています

次のViewModelにマップしようとしています

構成の使用

データベースからのクエリに EF6 を使用しています。Group.Tiersが nullの場合、問題が発生しています。null 値を処理するにはどうすればよいですか?

この構成を使用すると

このエラーが発生しています

タイプ 'System.Collections.Generic.ICollection' の要素を比較できません

0 投票する
0 に答える
99 参照

automapper - < AutoMapper 3.1 null -> 空の配列の動作を復元する

AutoMapper <= 3.0 では、次のテストに合格します。

バージョン 3.1 の時点で、destination.Data が以前のように空の配列ではなく null に設定されているため、should_map_array_to_empty アサーションは失敗します。構成されたマップごとに個別にではなく、できればグローバルに、以前の動作を復元する方法はありますか?

Mapper.Configuration.AllowNullCollections = falseこの場合、私が試した AutoMapper のバージョンに関係なく、構成オプションに違いはないようです。

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

c# - --aot-only を使用して実行中に Automapper を呼び出すと、Xamarin.iOS 例外がスローされます。



Xamarin を使用したデバッグ中に、AutoMapper (3.2.1.0) を iPad で動作させるのに問題があります。Xamarin Studio 3 と Xamarin.iOS 7.2.3.39 を使用して、ビルド ホストとして動作するように Mac をセットアップしました。私の Windows システムでは、Visual Studio 2012 を使用しています。私の ソリューション

には、次の 2 つのプロジェクトがあります


PortableClassLibrary プロジェクトには、次のコードがあります。

デバッガーを実行すると、次の例外が発生します。


..\packages\AutoMapper.3.2.1\lib\portable-windows8+net40+wp8+wpa81+sl5+MonoAndroid+MonoTouch\AutoMapper.dll
And
..\packages\AutoMapper.3.2.1\libを使用しようとしました\portable-windows8+net40+wp8+sl5+MonoAndroid+MonoTouch \AutoMapper.dll

しかし、これは例外に関して違いはありません。

Automapper が値の型を使用して辞書を作成しようとしているように見えますが、これは指定された URL に記載されている制限の 1 つです。

これを機能させるために欠けているものはありますか?

乾杯、

アンドレ

0 投票する
0 に答える
1570 参照

automapper - 同じタイプの複数のマッピング (異なるルール)

Automapperを使用して、ドメイン モデル ( nHibernate ) をビュー モデルにマップし、その逆にマップしています。すべてがとてもスムーズです。

ここで、エンティティ (ドメイン エンティティ) をそれ自体にマップする必要があるため、そこにいくつかのビジネス ルールを定義する必要があります。

同じ型に対して複数回異なるマッピングを定義する必要があります。私はすでに各タイプのマッピングにプロファイルを使用しています:

そして、これは私のプロフィールです(簡略化):

ご覧のとおり、 AfterMapでいくつかのことを行う必要があります。

私の 2 番目のプロファイルOrderToOrder2MapperProfileは、ここに示すものと似ているため、コードは貼り付けません。

オブジェクトをマッピングすると:

両方のプロファイルが処理されます。

SO で提案されたパスに従うことにし、「カスタム」エンジンを作成しました。

これで、行のマッピングを除いてすべて正常に動作します。カスタム エンジンを使用してオブジェクトをマップしている場合でも、両方のパイプが処理されます。

問題は、ここでシングルトンマッパー(エンジン)を使用しているという事実にあると思います。

プロファイラー内で現在のエンジンを使用する方法を見つけようとしましたが、それを取得できないようです。

唯一可能な解決策は、エンジンをプロファイラーのコンストラクターに渡すことです。

ここで現在のエンジンを使用します。

質問:

これが唯一の可能な解決策ですか、それともより良い代替手段がありますか?
私は物事を適切な方法で行っていますか?

誰かが興味を持っている場合は、 StructureMapをテスト ケースとして使用するgithub リポジトリを作成しました。

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

c# - Automapper IEnumerableIEnumerable へマップ構成を作成せずに

配列がCustomerContractの配列である場合、次を機能させることができません。

私の考えでは、最初の例で十分なはずですが、どちらも機能しません。automapper の構成 wiki ( https://github.com/AutoMapper/AutoMapper/wiki/Configuration ) を読みましたが、なぜこれが必要なのかわかりません。Automapper が必要とするものはすべて、コマンドで定義されています。それがどのタイプであるか(オブジェクトとリストの両方)、およびどのオブジェクトにマップするか。

Automapper のコアコンセプトを理解していないだけですか?

私の例外は次のように聞こえます:

タイプ マップ構成が欠落しているか、サポートされていないマッピングです。
マッピング タイプ:\r\nCustomerContract -> Customer\r\nStimline.Xplorer.Repository.CustomerService.CustomerContract -> Stimline.Xplorer.BusinessObjects.Customer
宛先パス: List`1[0]
ソース値: Stimline.Xplorer.Repository.CustomerService .CustomerContract

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

iqueryable - Automapper Extension Project() を使用するために IEnumerable を IQueryable に変換する

アプリケーションでストアド プロシージャをかなり頻繁に使用し、LinqToSql を使用してプロシージャを実行し、DB アクセス メソッドから返される List オブジェクトを設定します。ただし、AutoMapper と明らかに AutoMapper 拡張 Project() を使用して、一部のオブジェクトを別のオブジェクト タイプにマップする必要があります。To には IQuryable が必要ですが、List は IEnumerable を実装しています。

ソースコード:

コンパイルエラー:

System.Collections.Generic.List' には 'Project' の定義が含まれておらず、タイプ 'System.Collections.Generic.List' の最初の引数を受け入れる拡張メソッド 'Project' が見つかりませんでした (using ディレクティブがないか、またはアセンブリ参照?) folder\Common\MasterDataRepository.cs 116 28 Omnicx.Data

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

c# - Inconsistent Mapping Behavior in AutoMapper 3

I've had issues with AutoMapper 3 mapping related entities from entity framework to a view model some of the time in MVC 5. I'm using EF 6.1.1 to get the data, and a thin and light repository layer to centralize queries. That issue only seems to occur with mapping properties from entities under a root entity, but the problem is intermittent. I've seen the behavior start working again after rebuilding the solution and the behavior break after rebuilding the solution without changing the code where the issue occurs.

I've tested this in the debugger and SQL profiler, and even when the data isn't showing up on the front end, I can see in the SQL profiler that Entity Framework is loading the related tables.

Example mapping with the issue

This code executes in the MVC controller after the data has been queried from the repository layer. The view model will then be passed off to the view for rendering.

Another example mapping with the issue

Same basic execution path under a different controller action, same problem.

Again, sometimes the three properties get data, and sometimes they don't.

Data Model

This is what the Data Model looks like.

The part of the edmx file with the data model for this question

Repository

The repository layers wraps up the entity framework calls, but it does not abstract away the entity framework entities and the issues and benefits it has. All repositories in the project inherit IRepository, and I'm using this layer to centralize query and business logic.

Summary

I don't believe this is an Entity Framework lazy loading issue, and after forcing EF to eager load the data, the problem persists. The entities have the values in the debugger before mapping, but only sometimes will the value get mapped to the view model. The most frustrating thing is that the issue does not seem to be caused by any changes I've made to the view model.

What can cause such inconsistent behavior? I've had this problem with both AutoMapper 3.2.1 and 3.1.1.

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

entity-framework-6 - オートマッパーがエラーを引き起こしています: タイプマップ構成が欠落しているか、サポートされていないマッピング

Automapper は初めてです。

Nuget パッケージ - Automapper をマネージャー (BLL) と DAL レイヤーに追加しました。

さて、以下は関連するものです:

以下は、私に例外を与える Manager ライブラリのステートメントです。

例外は次のとおりです。

タイプ マップ構成が欠落しているか、サポートされていないマッピングです。

マッピング タイプ:
studentDTO -> StudentMaster
Admin.App.DTO.studentDTO-> Admin.App.DAL.StudentMaster

EF での select/where クエリの場合、機能しており、次を使用してマップできます

Autoconfiguration.cs私は次のようにファイルを書きました:

ノート:

両方のエンティティ - StudentMaster(モデル) エンティティとStudentDTO同じプロパティがあります。

この問題を解決する方法を教えてください。

ありがとうございました

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

.net - Xamarin Studio の使用時に AutoMapper NuGet がビルドされない

VS2013 によって作成され、GitHub でホストされているソリューションがあり、それがビルドされます。Xamarin Studio でビルドしようとしましたが、このエラーが発生します

ターゲット CopyAutoMapperAssembly の構築エラー: 条件 "$([System.String]::new('%(ReferencePath.Filename)').StartsWith('AutoMapper.'))" を解析できません: 句読点が無効です: [

プロジェクト ファイルからオプションを削除する NuGet パッケージの復元機能を無効にしましたが、問題は解決しません。

Xamarin Studio でプロジェクトを試してみたい場合、これはプロジェクトです: https://github.com/Ar3sDevelopment/Caelan.Frameworks.BIZ/tree/dev (dev ブランチのみが修正されています)