我想使用Entity-Framework 5.0作为带有PostgreSql数据库的O/R映射器.我已经阅读了许多HowTos,但我仍然被卡住了.也许我没有得到EF背后的全部想法.
我想要的是:
示例型号:
[Table("device")]
public class Device
{
[Key]
public int Id { get; set; }
[StringLength(255)]
public string Identifier { get; set; }
}
[Table("customer")]
public class Customer
{
public Customer()
{
this.Devices = new List<Device>();
}
[Key]
public int Id { get; set; }
[StringLength(255)]
public string Name { get; set; }
// attribute required?
public List<Device> Devices { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我做了什么:
DatabaseContext:
public class DatabaseContext : …Run Code Online (Sandbox Code Playgroud) 我正在努力使用JSON,ASP.NET,typescript/javascript和AngularJS进行我的Web应用程序设计.
简而言之:
我需要一种最佳实践,通过JSON从服务器向客户端发送数据,使用客户端的JSON字符串创建对象.
我有一个WebServerAPI项目(ASP.NET)具有以下结构:
模型类:
public class A {
public property int Id {get; set;}
public property string Name {get; set;}
public property Type Type {get; set;}
}
public class Type {
public property int Id {get; set;}
public property string Name {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
每个模型类的id属于数据库表(主键)中的id.
DataController结构:
public class DataController : ApiController {
// ...
// GET api/a
public IEnumerable<A> Get()
{
// fetches all As from the database
// the facade creates instances …Run Code Online (Sandbox Code Playgroud)