Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using ServiceStack;
- using ServiceStack.Text;
- using System.Collections.Generic;
- public class Car
- {
- public string Model {get; set;}
- public int Year {get; set;}
- public int MaxSpeed {get; set;}
- }
- public class TechRevision
- {
- public bool Ok {get; set;}
- public string RevisionDate {get; set;}
- }
- public class CarRevisionDbo
- {
- public Car Car {get; set;}
- public List<TechRevision> TechRevisions {get; set;}
- }
- public class CarRevisionDto
- {
- public string Model {get; set;}
- public int Year {get; set;}
- public int MaxSpeed {get; set;}
- public List<TechRevision> TechRevisions {get; set;}
- }
- var carRevisions = new []
- {
- new CarRevisionDbo
- {
- Car = new Car { Model = "BMW", Year = 2000, MaxSpeed = 190},
- TechRevisions = new List<TechRevision>
- {
- new TechRevision {Ok = true, RevisionDate = "2004"},
- new TechRevision {Ok = true, RevisionDate = "2008"}
- }
- },
- new CarRevisionDbo
- {
- Car = new Car { Model = "VW", Year = 2002, MaxSpeed = 190},
- TechRevisions = new List<TechRevision>
- {
- new TechRevision {Ok = true, RevisionDate = "2006"},
- new TechRevision {Ok = true, RevisionDate = "2010"}
- }
- }
- };
- var converted = carRevisions.ConvertTo<List<CarRevisionDto>>();
- System.Console.WriteLine(converted.ToJson());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement