public static EventsDto convertDBToDto(DAL.Event events) { return(new EventsDto() { eventCode = events.eventCode, eventDescription = events.eventDescription, eventNameId = events.eventNameId, eventStatusId = events.eventStatusId, startCallingDate = events.startCallingDate, heightPointAddress = events.heightPointAddress, widthPointAddress = events.widthPointAddress, eventName = events.EventName.discribeEventName, stringAddress = events.stringAddress, count = events.ValunteerEvents.Count }); }
static void Main(string[] args) { //Server-Local DAL.Event newEvent = new DAL.Event(); newEvent.journalId = "123"; newEvent.id = "1234"; newEvent.text = "aaaaa"; newEvent.x = 12; newEvent.y = 123; newEvent.time = DateTime.Now; //string jsonStr=DAL.Event.ClassToJson(newEvent); //Console.WriteLine(jsonStr); //服务器->本地 string str1 = JsonConvert.SerializeObject(newEvent); Console.WriteLine(str1); TravelMobileApp.DataModels.Event e2 = JsonConvert.DeserializeObject <TravelMobileApp.DataModels.Event>(str1); //本地->服务器 string str2 = JsonConvert.SerializeObject(e2); Console.WriteLine(str2); DAL.Event e3 = JsonConvert.DeserializeObject <DAL.Event>(str2); //Local处理 //TravelMobileApp.DataModels.Event localEvent = TravelMobileApp.DataModels.Event.JsonToClass(jsonStr); //Local-Server //string jsonStr2=TravelMobileApp.DataModels.Event.ClassToJson(localEvent); //Server处理 //DAL.Event e2=DAL.Event.JsonToClass(jsonStr2); //List测试 Console.Read(); }