Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

19 Experts available now in Live!

Get 1:1 Help Now