问题描述
我使用ValueInjecter代替AutoMapper。我试图用执行unflattening操作
I'm using ValueInjecter instead of AutoMapper. I'm trying to perform unflattening operation using
.InjectFrom<UnflatLoopValueInjection>(model)
它的工作原理,但我也想specity一些属性unflattening操作过程中忽略,例如写是这样的:
It works, but I would also like to specity some properties to ignore during the unflattening operation, for example writing something like:
.InjectFrom<UnflatLoopValueInjection>(new IgnoreProperties("Prop1", "Prop2"), model)
或
.InjectFrom<UnflatLoopValueInjection>(model).IgnoreProperties("Prop1", "Prop2")
任何想法?
推荐答案
你可以抓住源头code为UnflatLoopValueInjection并创建自己的注射有这个功能和其他任何你需要的。
you can grab the source code for the UnflatLoopValueInjection and create your own injection which has this feature and whatever else you need.
这里的$ C $下它:<一href="http://valueinjecter.$c$cplex.com/SourceControl/latest#ValueInjecter/UnflatLoopValueInjection.cs" rel="nofollow">http://valueinjecter.$c$cplex.com/SourceControl/latest#ValueInjecter/UnflatLoopValueInjection.cs
here's the code for it: http://valueinjecter.codeplex.com/SourceControl/latest#ValueInjecter/UnflatLoopValueInjection.cs
您可以添加一个被忽略的财产属性,或把它的构造函数,在这里你也行
you could add a Property Ignored properties or put it in the constructor, and where you have the line
var prop = sourceProp;
//add
if(ignoredProps.Contains(prop) continue;
这应该给你什么,你可以做一个快速的想法
this should give you a quick idea of what you can do
这篇关于ValueInjecter:如何忽略某些特性,同时执行.InjectFrom&LT; UnflatLoopValueInjection&GT;(数据)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!