?
Solved

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

Posted on 2014-10-10
4
Medium Priority
?
132 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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 …
Suggested Courses

762 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