Automapper and support for is*specified property

115 views
Skip to first unread message

hanze...@gmail.com

unread,
May 21, 2015, 5:11:15 AM5/21/15
to automapp...@googlegroups.com
Hello,
I would like to map domain object to dto by automapper. however generated dto uses "is*specified" bool attributes for optional elements and I have to set this properties manually.  
Has automapper any support for this issue?

Thanks
 

Shatl

unread,
May 22, 2015, 5:58:11 PM5/22/15
to automapp...@googlegroups.com, hanze...@gmail.com

Hi,
looks like you need to use .AfterMap() and update corresponding properties manually.
https://github.com/AutoMapper/AutoMapper/wiki/Before-and-after-map-actions

Another question is why do you need this?
Could it be replaced with nullable property and 
bool IsXxSpecified { get { return _xx.HasValue; }}
?

hanze...@gmail.com

unread,
Jun 9, 2015, 5:51:09 AM6/9/15
to automapp...@googlegroups.com, hanze...@gmail.com
Yeah, your proposition sounds good, but I don't want to change any code such as IsXxSpecified property because this code is generated by some visual studio tool. 
It's boring to replace code every time after generation of files (e.g. get modified xsd file). 

Jimmy Bogard

unread,
Jun 9, 2015, 8:19:31 AM6/9/15
to automapper-users
So no - there isn't. I'm planning on adding support for this via user-defined conventions in 4.0. Can you open a GitHub issue for this?

Thanks,

Jimmy

On Tue, Jun 9, 2015 at 4:51 AM, <hanze...@gmail.com> wrote:
Yeah, your proposition sounds good, but I don't want to change any code such as IsXxSpecified property because this code is generated by some visual studio tool. 
It's boring to replace code every time after generation of files (e.g. get modified xsd file). 

--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

egemen...@gmail.com

unread,
Sep 18, 2015, 7:54:06 AM9/18/15
to AutoMapper-users
Hey Jimmy,

Any news about this one?

9 Haziran 2015 Salı 15:19:31 UTC+3 tarihinde Jimmy Bogard yazdı:

Jimmy Bogard

unread,
Sep 18, 2015, 9:14:55 AM9/18/15
to automapper-users
Reply all
Reply to author
Forward
0 new messages