I just had the opportunity to use EF basically 1x. So, I have a lot of doubts, even though I'm consulting quite a bit with google. I have a client application that will pick up various Facebook data from the logged in user ...
Playing in Json2Charp I have the following classes:
public class UserData
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[JsonProperty("id")]
public string idface { get; set; }
public string name { get; set; }
public string birthday { get; set; }
public string email { get; set; }
public Hometown hometown { get; set; }
public Location location { get; set; }
public Events events { get; set; }
public Likes likes { get; set; }
public Age_Range age_range { get; set; }
public string gender { get; set; }
public Picture picture { get; set; }
}
public class Hometown
{
public string id { get; set; }
public string name { get; set; }
}
public class Location
{
public string id { get; set; }
public string name { get; set; }
}
public class Events
{
public Datum[] data { get; set; }
public Paging paging { get; set; }
}
public class Paging
{
public Cursors cursors { get; set; }
public string next { get; set; }
}
public class Cursors
{
public string before { get; set; }
public string after { get; set; }
}
public class Datum
{
public string description { get; set; }
public string name { get; set; }
public DateTime start_time { get; set; }
public Place place { get; set; }
public int attending_count { get; set; }
public string id { get; set; }
public string type { get; set; }
public string rsvp_status { get; set; }
public DateTime end_time { get; set; }
}
public class Place
{
public string name { get; set; }
public LocationEvent location { get; set; }
public string id { get; set; }
}
public class LocationEvent
{
public string city { get; set; }
public string country { get; set; }
public float latitude { get; set; }
public float longitude { get; set; }
public string state { get; set; }
public string street { get; set; }
public string zip { get; set; }
}
public class Likes
{
public Datum1[] data { get; set; }
public Paging paging { get; set; }
}
public class Datum1
{
public string category { get; set; }
public string name { get; set; }
public int fan_count { get; set; }
public string website { get; set; }
public string id { get; set; }
public LocationEvent location { get; set; }
public string[] emails { get; set; }
}
public class Age_Range
{
public int min { get; set; }
}
public class Picture
{
public Data data { get; set; }
}
public class Data
{
public bool is_silhouette { get; set; }
public string url { get; set; }
}
When creating a webapi to connect with my Azure SQL, I thought about using EF code first to make my life easier. I read about Inheritance and found it most suitable for my use. However, I believe my class would have to change for example:
public class UserData
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[JsonProperty("id")]
public string idface { get; set; }
public string name { get; set; }
public string birthday { get; set; }
public string email { get; set; }
}
public class Hometown : UserData
{
public string id { get; set; }
public string name { get; set; }
}
public class Location : UserData
{
public string id { get; set; }
public string name { get; set; }
}
E assim por diante....
Am I correct? Is this the right thing to do or can I get my class informed first? If yes, what would be the most correct to implement? TPT?
I also read about Complex Types.
But the question remains ... what to use.