Solved

I Am Getting an Error Value Supplied is of Type String Expected Suspense Data?

Posted on 2014-10-10
4
129 Views
Last Modified: 2014-10-19
I need my string input to be of SuspenseData type.

Is there a way to map the correct data type?

Thanks,

Dan

Here is my code:
    class SuspenseTypeListResolver : ValueResolver<SuspenseType[], List<SuspenseData>>
    {
        protected override List<SuspenseData> ResolveCore(SuspenseType[] source)
        {
            if (source == null || source.Length == 0) return null;

            return source.Select(Mapper.Map<SuspenseType, SuspenseData>).
                Where(su => su != null).ToList();
        }
    }

Open in new window

SuspenseData.cs File:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using BCA.ISS.DVS.Common;
using BCA.ISS.DVS.Model.Entities.Common;

namespace BCA.ISS.DVS.Model.Entities.Vehicle
{
    [Serializable]
    public class SuspenseData
    {
        public string SuspenseCode { get; set; }

        public string SuspenseCodeText { get; set; }

        public string SuspenseSatisfied { get; set; }
    }
}

Open in new window

SuspenseType:
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://bca-xml.x.state.mn.us/DVSServices/1.0")]
    [System.Xml.Serialization.XmlRootAttribute("Suspense", Namespace="http://bca-xml.x.state.mn.us/DVSServices/1.0", IsNullable=false)]
    public partial class SuspenseType {
        
        private string suspenseCodeField;
        
        private string suspenseCodeTextField;
        
        private string suspenseSatisfiedField;
        
        /// <remarks/>
        public string SuspenseCode {
            get {
                return this.suspenseCodeField;
            }
            set {
                this.suspenseCodeField = value;
            }
        }
        
        /// <remarks/>
        public string SuspenseCodeText {
            get {
                return this.suspenseCodeTextField;
            }
            set {
                this.suspenseCodeTextField = value;
            }
        }
        
        /// <remarks/>
        public string SuspenseSatisfied {
            get {
                return this.suspenseSatisfiedField;
            }
            set {
                this.suspenseSatisfiedField = value;
            }
        }
    }

Open in new window


Automapper Code:
                Mapper.CreateMap<SuspenseType, SuspenseData>()
                   .ForMember(sd => sd.SuspenseCode, m => m.ResolveUsing<SuspenseCodeResolver>().FromMember(s => s.SuspenseCode))
                   .ForMember(sd => sd.SuspenseCodeText, m => m.ResolveUsing<SuspenseCodeTextResolver>().FromMember(s => s.SuspenseCodeText))
                   .ForMember(sd => sd.SuspenseSatisfied, m => m.ResolveUsing<SuspenseSatisfiedResolver>().FromMember(s => s.SuspenseSatisfied))
                    ;

                Mapper.CreateMap<VehiclesType, VehicleDetail>()
                    .ForMember(vd => vd.Liens, m => m.ResolveUsing<LiensResolver>().FromMember(s => s.Liens))
                    .ForMember(vd => vd.Owners, m => m.ResolveUsing<VehicleOwnerResolver>().FromMember(s => s.OwnerInformation))
                    .ForMember(vd => vd.CompanyOwners, m => m.ResolveUsing<VehicleCompanyOwnerResolver>().FromMember(s => s.OwnerInformation))
                    .ForMember(vd => vd.Lessees, m => m.MapFrom(s => s.LesseeInformation))
                    .ForMember(vd => vd.PreviousOwners, m => m.ResolveUsing<PreviousOwnerListResolver>().FromMember(s => s.PreviousOwnerInformation))
                    .ForMember(vd => vd.SuspenseData, m => m.ResolveUsing<SuspenseTypeListResolver>().FromMember(s => s.SuspenseInformation))
                    ;

Open in new window

0
Comment
Question by:danielolorenz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Expert Comment

by:louisfr
ID: 40374988
Could you show how you call Resolve?
0
 

Accepted Solution

by:
danielolorenz earned 0 total points
ID: 40380279
I solved the problem.  I did not need to use a resolver on the data set.
0
 

Author Closing Comment

by:danielolorenz
ID: 40389832
My solution worked
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question