Automapper mapping properties on a condition

Hi there,
I appreciate if anyone could assist me please?
I am using AutoMapper but i am finding it difficult to map the contents depending on a condition.
e.g
I have a parameter called includeOptional which can be either null or 1 .
If it is null I do not want to map the additional properties to the destination. The properties in the destination are nullable.
if the value is 1 I would like to map the additional elements.
Currently i am mapping everything from the source to destination as i am finding it difficult to map.
I will share some of my code:
IEnumerable<CustomersDAO> customers = databaseProvider.GetCustomersById(CustId);
//additional processing..
var result = null;
if(includeOptional == null)
result = Mapper.Map<List<CustomerDAO>, Customer[]>(customers);
else
result = Mapper.Map<List<CustomerDAO>, Customer[]>(customers);
How would i go about mapping the properties from source to destination for each of the customers in the collection if the condition is met.
I have the following but i cannot seem to get it work.
configuration.CreateMap<CustomerDAO, Customer>()
ForMember(dto => dto.StartDate, opt => opt.MapFrom(src => src.StartDate))
.ForMember(dto => dto.Name, opt => opt.MapFrom(src => src.Name))
.ForMember(dto => dto.Category, opt => opt.MapFrom(src => src.Category));

Hello IndusKing,
From your description, it seems that your issue is related the usage of the Automapper, for this, I suggest that you could post Automapper related issues to the Automapper specific forum:
https://github.com/AutoMapper/AutoMapper/issues
The current forum is used for Entity Framework.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to keep MAPI properties when processing message data in RFC822 format in an Exchange Server 2007/2010 transport agent?

    We are developing an agent listening for the submit or endOfData event from the Exchange Server. Due to various reasons we need to convert the Exchange Mail
    internally to RFC822 format.
    So our MessageProcessor internally converts the message stream (usually TNEF) into RFC822 format. This means when written our modified content back to ‘e.MailItem’
    we write the converted content back.
    It seems that this conversion causes a loss of some MAPI properties of the message.
    When out-of-office-mails are enabled for an account the Exchange Server generates both messages the OOF message for internal recipients and the OOF message external
    recipients.
    When sending an internal message using voting buttons the message arrives without that voting information.
    void Agent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
    MessageProcessor proc = new MessageProcessor();
    Stream messageContent = e.MailItem.GetMimeReadStream();
    Stream processedMail = proc.ProcessExchangeMessage(messageContent); // internally converts the message to RFC822
    Stream writeStream = e.MailItem.GetMimeWriteStream();
    processedMail.CopyToStream(writeStream);
    We also tried a dirty „hack“ using the Exchange Server internal method for converting the message from TNEF to RFC822 “ConvertAnyMimeToMime” from “Microsoft.Exchange.Data.Storage.OutboundConversionOptions”,
    but using that method causes the same issue.
    Now my idea was cloning all MAPI properties not related to the content of a message and reapply them after writing the RFC822 content back to into e.MailItem.
    Any idea how we can overcome our problems?
    Best regards,
    Harald Binkle
    Exchange Server Toolbox |
    SmartPOP2Exchange |
    SpamAssassin
    JAM Software GmbH
    Max-Planck-Str.22 * 54296 Trier * Germany
    http://www.jam-software.com

    Hello Scott,
    after posting this question I implemented a dirty workaround.
    Now I'd like to ged rid of that workaround. Are you still not allowed to discuss this?
    Best regards,
    Harald Binkle
    Exchange Server Toolbox |
    SmartPOP2Exchange |
    SpamAssassin
    JAM Software GmbH
    Am Wissenschaftspark.26 * 54296 Trier * Germany
    http://www.jam-software.com

  • Syndication Map properties Issues!!!!!!!!!

    Hi Guru's,
    I am having some issue while doing settings for "SYNDICATING ALL RECORDS TO ONE XML FILE".
    I had followed instruction as per SYndication guide pg 140,where it says:-
    To syndicate all records to a single XML file
    1. On the Map Properties tab, click in the Value cell of the XML File
    Output property and select Single File (All Records) from the drop-down
    list.
    2. Click in the Value cell of the Repeating Record Node property and
    select the repeating XML element which contains the record structure
    But the issue is when i do the above still field "Repeatable record Name/Node" is greyed out and doesnot allow me to select IDOC segment.
    So is this the issue with XML schema file OR is there something i am doing wrong?
    Please let me know if anyone has got these issues..
    Regards
    Vikrant M Kelkar.

    Hi Preethi,
    Thanks for your reply.
    Issue is, we had a XSD to which we added/extended some more fields..As a result root node of XSD was changed  and the whole map now needs to be redone.
    Old XSD was/is still allowing us to select Segment in Reapaetable node in Map Properties, but new XSD doesnot allow .
    How is this possible that for same MDM version system allows to choose  Repeatable node segment selection(in Map Properties tab) for one XSd and stops doing it for other?
    Also if we dont select the repeatble node how will you map qualified tables?
    Regards
    Vikrant M Kelkar

  • Log MAPI Properties

    Hi,
    I would like to monitor all MAPI Properties that are sent from an Outlook client during the sending process of an EMail.
    Is there a way to configure Exchange's logging to meet such a requirement?
    Thanks for your help
    Tobias

    Hi Tobias,
    I recommend you use the Microsoft® Exchange Server User Monitor (EXMON) tool to monitor: 
    Microsoft Exchange Server User Monitor
    Using ExMon, administrators can view the following:
    IP addresses used by clients
    Microsoft Office Outlook® versions and mode, such as Cached Exchange Mode and classic online mode
    Outlook client-side monitoring data
    Resource use, such as:
    CPU usage
    Server-side processor latency
    Total latency for network and processing with Outlook 2003 and later versions of MAPI
    Network bytes
    Best regards,
    Niko Cheng
    TechNet Community Support

  • I need date mapping Below based on condition?

    Source sidefield:ZALDAT
    Taget Structure mapping condition:
    Format MMDDYY. If check is voided then it should be '000000'
    Taget field:Issue date
    I Need how to mapping source to target field based on conditioin explain me?give me saple mapping given condition?

    Hi,
    Try this udf
    youir input for this udf is "date" (which is a string)
    SimpleDateFormat sdf = new SimpleDateFormat("MMddyy");
    Date testDate = null;
    try
          testDate = sdf.parse(date);
    catch (ParseException e)
         return '000000';
    if (!sdf.format(testDate).equals(date))
        return '000000';
    return testDate.toString();
    code taken and modified from  http://www.dreamincode.net/forums/showtopic14886.htm
    Regards
    suraj
    Edited by: S.R.Suraj on Sep 29, 2009 7:53 AM

  • Create two logical columns with same LTS mapping but diff filter conditions

    Hi,
    Problem:
    How to create two logical columns within same logical table mapped to same physical column but different filter conditions?
    I have a scenario where in,
    Physical layer columns
         - table1.employee
         - table1.emp_city
    I need a columns in logical layer:
    Logical layer - lt1.count_emp_delhi (counts distinct employees whose city_name = 'Delhi')
              lt1.count_emp_mumbai(counts distinct employees whose city_name = 'Mumbai')
    My approach:
    For Delhi column
    1. Create a logical column lt1.count_emp_delhi mapped to the physical column table1.employee
    2. Aggregate using countdistinct in aggregate tab.
    3. Edit the mapping condition
         3.1. Use the where clause and set table1.emp_city='Delhi'.
    For Mumbai column.
    Followed the same approach as above but in 3.1 if I change the condition to 'Mumbai', even the delhi column is populated with mumbai count which is ERRONEOUS
    Could some one please help?

    Hi,
    1. Create two alias tables for table1 in Physical Layer. Lets say TB_Mumbai and TB_Delhi
    2. Create a logical table in BMM layer (D1 Employee Cities )
    3. Drag and drop the employee & emp_city columns from both alias tables (TB_Mumbai and TB_Delhi ) into your newly created logical table.
    4. Now you can see two Logical Table Sources (TB_Mumbai and TB_Delhi )
    5. Now using Where condition, write the condition on each table
    NOTE: Don't write any condition on the Physical table Table1.
    Hope it helps you.
    Regards,
    Kalyan Chukkapalli
    http://123obi.com

  • EDI Mapping based on a condition

    Hi All,
    Can we use some condition to differentiate different mappings based on the source feild?
    My scenario is the invoice from R/3 is imported into XI and based on a feild Receiver company code&Company name  , different mappings needs to be executed and please keep in mind (different mappings include include verisons like EDIFACT, TRADACOM etc)
    Please guide me!!
    Thanks,
    Smith

    Hi Peter,
    Thanks for your reply. As per my understanding,
    If we have 4 customers whom we need to send invoices based on the company code and description,
    The following needs to be created:
    one outbound interface in PI(Idoc from R/3 )
    Four inbound interfaces from PI to EDI
    Four different mappings
    In receiver determination based on the condition the message mapping is selected and delivered .
    Please confirm
    Thanks,
    Smith

  • XSLT Mapping issue. If condition.

    Hi,
    A and B are in Source Structure.   "C" is in Target Structure.
    If "A"  value has between 5001 and 6999 then pass "B" to C.
    How to do this in XSLT map?
    Thanks
    Deepthi

    Code:
    - <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    - <xsl:for-each select="POS/Detail">
    - <xsl:if test="(POS/Detail/FieldA > 5000) and (POS/Detail/FieldA < 7000)">
    - <xsl:call-template name="insert_E1WPF02">
      <xsl:with-param name="ReferenceNo" />
      <xsl:with-param name="ItemNo" />
      <xsl:with-param name="Amount" />
      </xsl:call-template>
      </xsl:if>
      </xsl:for-each>
    - <xsl:template name="insert_E1WPF02" match="/">
      <xsl:param name="ItemNo" />
      <xsl:param name="Amount" />
      <xsl:param name="RefernceNo" select="POS/Detail/FieldB" />
    - <ZUONR>
      <xsl:value-of select="$ReferenceNo" />
      </ZUONR>
    - <POSNR>
      <xsl:value-of select="$ItemNo" />
      </POSNR>
    - <WRBTR>
      <xsl:value-of select="$Ammount" />
      </WRBTR>
      </xsl:template>
      </xsl:stylesheet>
    I Cannot use  <xsl:template name="insert_E1WPF02> twice because it is creating 2 E1WPF02 Segments in Idoc for each transaction which is not correct.

  • Windows Network Drive Mapping properties not being associated with Test Stand deployment

    I recently upgraded a TestStand/LabVIEW (Developer Suite 2012 DS1) deployment project from a Windows XP Pro OS to Windows 7 Enterprise. Now, when I run the Test Stand deployment, Network paths that used to be hard coded into my File Globals are no longer recognized. I re-wrote the vi's, and put "File Dialog" pop-ups so that I could see what path the control is being opened up at, and what appears to be happening is the Network Drive that I am defaulted to is appearing as if it is "disconnected" in the navigation window, and the path is defaulted to my root directory. I can navigate out to my network path no problem from the navigation window, and after the first time I perform this user action, subsequent executions open up to the path I have hard coded in my Sequence File Globals. However, if I reboot my host computer, I again have to go through the exercise of manually pointing to the proper network location? If I use the Windows Explorer to check Mapped Networked Drives, everything is properly mapped and connected.
    Has anyone ever seen this behavior? 

    Hi ATE Dude 22,
    I have not come across this problem before but here is a document from MSDN and one from NI which discuss file path conventions. From what I've seen, UNC is also accepted under Windows XP so I would advise using it for your file globals.
    Cheers,
    KyleP
    Applications Engineer
    National Instruments

  • SETTING PROPERTIES FOR A MAPPING VIA OMBPLUS ISN'T WORKING

    Hi, i have a problem with OMBPLUS:
    I have a script which creates a mapping and then is supposed to change properties for the mapping and seems to do so via OMBRETRIEVE. But when looking in OWB the properties aren't changed.
    If I change any of the properties inside OWB and then run the script again, then the properties are changed. Does anyone know why the behavior is like this?
    /thanx Joel
    When running the script the output looks like this:
    CREATE MAPPING 'XXX_1_IN'... DONE
    DEFAULT_OPERATING_MODE={SET BASED FAIL OVER TO ROW BASED}
    ALTER MAPPING PROPERTIES FOR 'T_A_TEST_XXX_1_IN'... DONE
    DEFAULT_OPERATING_MODE={SET BASED}
    -- ALL DONE --
    The script:
    set temp_module "TMP"
    set tmp_table1 "XXX_1"
    set tmp_table2 "XXX_2"
    set map_name "XXX_1_IN"
    puts -nonewline "CREATE MAPPING '$map_name'... "
    OMBCREATE MAPPING '$map_name' \
    ADD TABLE OPERATOR '$tmp_table1' BOUND TO TABLE '../$temp_module/$tmp_table1' \
    ADD TABLE OPERATOR '$tmp_table2' BOUND TO TABLE '../$temp_module/$tmp_table2' \
    ADD CONNECTION \
    FROM GROUP 'INOUTGRP1' OF OPERATOR '$tmp_table1' \
    TO GROUP 'INOUTGRP1' OF OPERATOR '$tmp_table2'
    OMBCOMMIT
    puts "DONE"
    set prop [OMBRETRIEVE MAPPING '$map_name' GET PROPERTIES (DEFAULT_OPERATING_MODE) ]
    puts "DEFAULT_OPERATING_MODE=$prop"
    puts -nonewline " ALTER MAPPING PROPERTIES FOR '$map_name'... "
    OMBALTER MAPPING '$map_name' \
    SET PROPERTIES (DEFAULT_OPERATING_MODE) \
    VALUES ('SET BASED')
    OMBCOMMIT
    set prop [OMBRETRIEVE MAPPING '$map_name' GET PROPERTIES (DEFAULT_OPERATING_MODE) ]
    puts "DEFAULT_OPERATING_MODE=$prop"
    puts "-- ALL DONE --"
    puts ""
    OMBDISCONNECT

    Thanks for your idea Roman, but it doesn't solve my problem.
    The problem is regardless of which property (Runtime parameters in OWB) I try to change. Before ANY property is changed via OWB (GUI) the changes via OMB doesn't come to effect (even if RETREIVE after OMBCOMMIT says so).
    Regards, Joel

  • SETTING PROPERTIES FOR A MAPPING VIA OMBPLUS ISN'T WORKING (OWB10gR2)

    Hi, i have a problem with OMBPLUS:
    I have a script which creates a mapping and then is supposed to change properties for the mapping. The script worked in previous releases of OWB but after upgrading to 10gR2 I get an error that DEFAULT_OPERATING_MODE property does not exist.
    Does anyone know why I get the error?
    /thanx Joel
    When running the script the output looks like this:
    CREATE MAPPING 'XXX_1_IN'... DONE
    DEFAULT_OPERATING_MODE={SET BASED FAIL OVER TO ROW BASED}
    ALTER MAPPING PROPERTIES FOR 'T_A_TEST_XXX_1_IN'...
    OMB02902: Error setting property DEFAULT_OPERATING_MODE of T_A_TEST_XXX_1_IN: MMM1034: Property DEFAULT_OPERATING_MODE does not exist.
    -- ALL DONE --
    The script:
    set temp_module "TMP"
    set tmp_table1 "XXX_1"
    set tmp_table2 "XXX_2"
    set map_name "XXX_1_IN"
    puts -nonewline "CREATE MAPPING '$map_name'... "
    OMBCREATE MAPPING '$map_name' \
    ADD TABLE OPERATOR '$tmp_table1' BOUND TO TABLE '../$temp_module/$tmp_table1' \
    ADD TABLE OPERATOR '$tmp_table2' BOUND TO TABLE '../$temp_module/$tmp_table2' \
    ADD CONNECTION \
    FROM GROUP 'INOUTGRP1' OF OPERATOR '$tmp_table1' \
    TO GROUP 'INOUTGRP1' OF OPERATOR '$tmp_table2'
    OMBCOMMIT
    puts "DONE"
    set prop [OMBRETRIEVE MAPPING '$map_name' GET PROPERTIES (DEFAULT_OPERATING_MODE) ]
    puts "DEFAULT_OPERATING_MODE=$prop"
    puts -nonewline " ALTER MAPPING PROPERTIES FOR '$map_name'... "
    OMBALTER MAPPING '$map_name' \
    SET PROPERTIES (DEFAULT_OPERATING_MODE) \
    VALUES ('SET BASED')
    OMBCOMMIT
    puts "-- ALL DONE --"
    puts ""
    OMBDISCONNECT

    Hi, don't look at the script it was copied and pasted from an old thread. The problem is the error I get when trying to execute:
    OMBALTER MAPPING 'map_name' \
    SET PROPERTIES (DEFAULT_OPERATING_MODE) \
    VALUES ('SET BASED')
    OMB02902: Error setting property DEFAULT_OPERATING_MODE of map_name: MMM1034: Property DEFAULT_OPERATING_MODE does not exist.
    //Joel

  • SRM 7.0 pricing conditions mapping to the backend system

    Experts,
      I am new to SRM & working in SRM 7.0.  I have a serious problem in distributing the pricing conditions.
      I need to distribute/map the pricing conditions in SRM 7.0 to the backend ECC system.  I need step by step procedure for the same.  Plz help me.

    Hi,
      with the help of SDN, i have done the mapping part of pricing conditions as below.
      field-symbols:
        <ls_be_item>      type BBPS_CTR_ITEM,
        <ls_be_cond>      type BBPBAPICONDCT,
        <ls_be_cond_bapi> type BBPBAPICONDIT.
      loop at ct_be_items assigning <ls_be_item>.
        if <ls_be_cond>-COND_TYPE = '0100'.
          <ls_be_cond>-COND_TYPE = 'PB00'.
        elseif <ls_be_cond>-COND_TYPE = '01CT'.
          <ls_be_cond>-COND_TYPE = 'PBXX'.
        elseif <ls_be_cond>-COND_TYPE = '01RA'.
          <ls_be_cond>-COND_TYPE = 'RB00'.
        elseif <ls_be_cond>-COND_TYPE = '01RP'.
          <ls_be_cond>-COND_TYPE = '01RP'.
        ENDIF.
        if <ls_be_cond_bapi>-COND_TYPE = '0100'.
          <ls_be_cond_bapi>-COND_TYPE = 'PB00'.
        elseif <ls_be_cond_bapi>-COND_TYPE = '01CT'.
          <ls_be_cond_bapi>-COND_TYPE = 'PBXX'.
        elseif <ls_be_cond_bapi>-COND_TYPE = '01RA'.
          <ls_be_cond_bapi>-COND_TYPE = 'RB00'.
        elseif <ls_be_cond_bapi>-COND_TYPE = '01RP'.
          <ls_be_cond_bapi>-COND_TYPE = '01RP'.
        ENDIF.
      endloop.
    But the problem is, when i put the external break point in the above code, its not getting triggered.  Can any plz tell me how to debug the code.

  • Can we add links to perform editing, modify properties in KM Report output?

    Hello,
    I have created KM report which provides list of XML forms which satisfy specific conditions. Now I want to add links on report output so that user can click on that link and can directly start editing documents if needed. Also I want to provide direct link which can open properties of document.
    Also can we add images/ icons on a particular row like traffic lights icons: Green, Yellow, Red.
    Thank you,
    Nitesh Shelar

    I have another question related to following class may be that can put more light on my base requirement. I am creating Result item object based on details I found on various KM articles for KM reports. I wonder what is that List executedCommands, object.
    public static ResultItem getInstance(RID rid,
                                         Map properties,
                                         List executedCommands,
                                         boolean hadError,
                                         String statusDescription)
    Can any one tell me about this List executedCommands and what exactly I should pass there and how it is going to affect my output?

  • Syndicate depending on condition to a target field

    HI,
    I am a scenario where I need to syndicate out the value depending up on the condition:
    Source:
    Remote System --AAA
    value1---111
    valu2---- null
    Another record:
    Remote System --BBB
    value1---333
    valu2----444
    Target has two fields: System and Value
    Condition is : When ever remote system is BBB then I need to pass value2 to Target Value field any thing else I need to pass Vlaue1 value to Value target field...
    Is this possible in MDM Syndication?
    Thanks
    Rajeev

    Hi Rajeev,
    Yes it is possible in MDM 7.1 version
    create two seprate map for each system (AAA,BBB) i.e.  and set condition on each system
    follow the the which may help you
    1. Create field to field Map
    2. In Map Properties Tab ---> Remote Key Over ride (AAA) & tiick suppress unchaged records
    3. Specify Value1 = 111 and Value2= Null in free form serach
    4. SAve map by selecting Remote System in our case it would be AAA
    5. Give Map name & Save
    follow same step for remote system BBB it will work
    Note : Based on your Condition set in free form serach mapping will execute accordingly for perticuler system
    Thanks,
    Jignesh Patel
    Edited by: jignesh patel on Sep 6, 2010 4:06 PM

  • VLD-2754 - attributes of update matching criteria are not mapped

    For some reason, when we define a cube that uses a particular dimension, the mapping always fails with the error:
    "If an attribute is used in the matching criteria but is not mapped, then the matching condition cannot be determined. For the attributes (DIM_CT) to be used for matching, they must be mapped for TEST_CUBE. To deselect an attribute as a matching criteria, set Update Use For Matching to No."
    I can't seem find an option for Update Use For Matching. On my source table, I have some options for matching keys but I don't understand exactly how that pertains to the mapping target.

    Hi,
    You must be dealing with an update, upsert or insert update mapping here. Check the attribute properties of the fields on your target table. You should find the 'Update Use For Matching' property there.

Maybe you are looking for