Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have waste lots of time in this, still scratching my head. I have this WCF service in my project ::

C#
namespace XYZ.ABC.Services.ServiceObjects
{
 [DataContract]
    public class SpecimenType
    {
        [DataMember]
        public DateTimeOffset CreateDate { get; set; }

        [DataMember]
        public DateTimeOffset? UpdatedDate { get; set; }
     }
}

using Technossus.LIS.Services.ServiceObjects;

namespace Technossus.LIS.Services.InterFaces
{
    [ServiceContract]
    public interface IDosService
    {
      [OperationContract]
        IEnumerable<SpecimenType> GetAllSpecimenType();
    }
}


using XYZ.ABC.Services.InterFaces;

namespace XYZ.ABC.Services
{
 public class DosService : ServiceBase, IDosService
    {
 public IEnumerable<SpecimenType> GetAllSpecimenType()
        {
            IEnumerable<SpecimenType> result = null;
            var manager = new DOSManager(SecurityUserId);

            var specimenList = manager.GetSpecimenTypeList();
            result = Mappe
            r.Map<ienumerable><specimentype>>(specimenList);
            return result;
        }
}

Model on client side
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace XVZ.ABC.Web.Models
{
    public class SpecimenTypeModel
    {
   public DateTimeOffset CreateDate { get; set; }

        public DateTimeOffset? UpdatedDate { get; set; }
}
}

Controller

C#
using System.Collections.Generic;
using System.Web.Mvc;
using Technossus.LIS.Web.Models;
using Technossus.LIS.Web.DosService;
using AutoMapper;


namespace Technossus.LIS.Web.Controllers
{
    public partial class DosController : BaseController
    {
        //
        // GET: /Dos/
        public virtual ActionResult SpecimenTypes()
        {
            //IEnumerable<specimentypemodel> model = null;
            List<specimentypemodel> model = null;
            using (var client = new DosServiceClient())
            {
                var serviceUser = client.GetAllSpecimenType();

                foreach (var servicelist in serviceUser)
                {
                    SpecimenTypeModel objspecimentype = new SpecimenTypeModel();
                    objspecimentype.SpecimenTypeName = servicelist.SpecimenTypeName;
                    objspecimentype.SpecimenTypeCode = servicelist.SpecimenTypeCode;
                    objspecimentype.CreateDate = servicelist.CreateDate;
                    objspecimentype.UpdatedDate = servicelist.UpdatedDate;
                    model.Add(objspecimentype);
                }
                //model = Mapper.Map<list><specimentypemodel>>(serviceUser);
            }

            return View(model);
        }



But the problem is CreatedDate and updatedate is not serializing in System.Datetimeoffset its taking as xvz.Abc.Service.DateTimeoffset only and other properties are converting fine like specimentypename and code both are converting into string only.

Please help me in this please I have stuck in this , Because we have to map this

Regards
Raman
Posted
Updated 14-Nov-13 2:37am
v2
Comments
SomeGuyThatIsMe 14-Nov-13 13:39pm    
have you looked at the actual messages being sent back and forth, if you're using xml this may help. it was the first link in a quick search about your issue

http://stackoverflow.com/questions/9172380/wcf-datetimeoffset-compatibility
Ambivert 15-Nov-13 7:38am    
yes its not converting to my service class.datetimeoffset to System.datetimeoffset

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900