Syntax for representing reference key while we writing clasess for Tables in our app (c#).

I have tables in sqlAzure DB , i have a mobile service to connect to that database. Here in my app i am creating clasess for those tables, in those some tables have reference key columns, how to represent that reference key( foreign key) when i am writing class for that table (c#).

something Like this

[JsonProperty(PropertyName = "LocationId")]
        [ForeignKey("Id")]
        public string LocationId { get; set; }
        public virtual Location Location { get; set; }


October 9th, 2013 3:52pm

Hello,

It seems that you create a table with Entity Framework and you want to add a foreign keys association. Starting with the .NET Framework version 4, you can expose foreign key properties on entity types and define relationships through foreign keys.
Reference:http://msdn.microsoft.com/en-us/library/vstudio/ee794150(v=vs.100).aspx

If you have more question about Entity Framework design, you can post the question in the ADO.NET Entity Framework forum.It is appropriate and more experts will assist you.

Regards,
Fanny Liu

Free Windows Admin Tool Kit Click here and download it now
October 10th, 2013 8:19am

No i am not using Entity framework, i just created one mobile service in azure and created two tables one child to other, and i manually created classes in my windows store app project sample, now i got doubt that how to represent foreign key of a property in one class to another class property... in wpf i know but in store app i have no idea how to represent, when i use same syntax in store app it isnt working means showing error.

October 12th, 2013 9:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics