Do I need to use POCO classes with Entity Framework 6?

The following class was automatically generated from the template using the Entity Framework model.

namespace Entities
{
    using System;
    using System.Collections.Generic;

    public partial class Country
    {
        public Country()
        {
           this.Regions = new HashSet<Region>();
        }

        public long CountryId { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        public bool Preferred { get; set; }
        public System.DateTime LastChanged { get; set; }

        public virtual ICollection<Region> Regions { get; set; }
   }
}

I have a Wcf web service that returns only POX (Xml) and Json. I want to return my own serialized object, for example:

public class MyResponseObject
{
    public int RequestId {get;set;}
    public List<Country> CountryList {get;set;}
    //other properties
}

But I do not want to return an ICollection of regions.

Then the object can be returned using something like

Newtonsoft.Json.JsonConvert.SerializeObject ()

Will I best get my own serialized POCO object back this way?

+4
source share
1 answer

In projects like these, your classes can be divided into two types:

  • Database Object Objects (Entity Framework Works With)
  • ( WCF -)

, , , ( -). API. -, Users ( UserId, Password ), , Password !

, webservice (, ), , .

, , , .

, , AutoMapper, .

+8

Source: https://habr.com/ru/post/1530207/


All Articles