Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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:…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
This is an introductory video for CloudBerry Managed Backup. You will learn how to sign up with the service and get started in a few minutes.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now