Solved

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

Posted on 2014-10-10
4
130 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

690 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