Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 我需要用许多表映射复杂的类型关系_.net_Angular_Entity Framework_Api_Orm - Fatal编程技术网

.net 我需要用许多表映射复杂的类型关系

.net 我需要用许多表映射复杂的类型关系,.net,angular,entity-framework,api,orm,.net,Angular,Entity Framework,Api,Orm,好的,我有这门课“Opciones”,很抱歉是西班牙语的。要理解的主要事情是,我有一个类'Opciones',它在'Registro'中有自己的多个实例,我找不到一种方法来映射实体框架,我使用迁移,因为我必须坚持数据库的结构。我让它从数据库中检索数据,但当它到达复杂类型的字段时,它只会在属性值中带null和0 我尝试在OnModelCreating方法中配置映射,但没有任何效果,它最终要求使用“propertyNameId”,如TipoClientId列,我希望它继续在opciones表中搜索,

好的,我有这门课“Opciones”,很抱歉是西班牙语的。要理解的主要事情是,我有一个类'Opciones',它在'Registro'中有自己的多个实例,我找不到一种方法来映射实体框架,我使用迁移,因为我必须坚持数据库的结构。我让它从数据库中检索数据,但当它到达复杂类型的字段时,它只会在属性值中带null和0

我尝试在OnModelCreating方法中配置映射,但没有任何效果,它最终要求使用“propertyNameId”,如TipoClientId列,我希望它继续在opciones表中搜索,并根据在属性中找到的id检索信息,但对我的应用程序来说,它是一个类的属性,它本身就是一个对象。这是我第一次处理实体框架和映射,所以任何关于这个问题的澄清都会受到欢迎

public class Registro
    {
        public int Id { get; set; }
        public string usuarioRed { get; set; }
        public DateTime fechaLlamada { get; set; }
        public DateTime fechaDevolucion { get; set; }
        public Opciones tipoCliente { get; set; }
        public Opciones motivoDevolucion { get; set; }
}

public class Opciones
    {
        public int Id { get; set; }
        public string descripcion { get; set; }
        public Boolean activo { get; set; }
        public int idDependencia { get; set; }
    }

对于实体框架,要在实体之间创建关系,必须添加ID和对象

public class Registro
    {
        public int Id { get; set; }
        public string usuarioRed { get; set; }
        public DateTime fechaLlamada { get; set; }
        public DateTime fechaDevolucion { get; set; }

        public int tipoClienteId { get; set; }
        public Opciones tipoCliente { get; set; }

        public int motivoDevolucionId { get; set; }
        public Opciones motivoDevolucion { get; set; }
}

对于实体框架,要在实体之间创建关系,必须添加ID和对象

public class Registro
    {
        public int Id { get; set; }
        public string usuarioRed { get; set; }
        public DateTime fechaLlamada { get; set; }
        public DateTime fechaDevolucion { get; set; }

        public int tipoClienteId { get; set; }
        public Opciones tipoCliente { get; set; }

        public int motivoDevolucionId { get; set; }
        public Opciones motivoDevolucion { get; set; }
}

首先,你是不是想把它映射成角度?如果是这样的话,你是用角度来获取数据的吗?如果是这样,请显示您的角度代码。在db中,是否注册为opciones一对多?因为这种关系将在ef中起作用。它将fk存储到registro中的opciones。是的,我试图在angular项目中使用数据,但我在不同的项目中使用后端和前端,后端是.net api,我正在与postman进行测试。我发现很难在DB中解释这些实体之间的关系,假设Registro或任何其他实体只是“使用”opciones中的数据,您在Registro中找到的是指向opciones中记录的id,它应该是简单的一对一关系,但opciones作为一个实体在其他实体中被多次实例化。首先,您是否尝试将其映射为Angular?如果是这样的话,你是用角度来获取数据的吗?如果是这样,请显示您的角度代码。在db中,是否注册为opciones一对多?因为这种关系将在ef中起作用。它将fk存储到registro中的opciones。是的,我试图在angular项目中使用数据,但我在不同的项目中使用后端和前端,后端是.net api,我正在与postman进行测试。我发现很难在DB中解释这些实体之间的关系,假设Registro或任何其他实体只是“使用”opciones中的数据,您在Registro中找到的是指向opciones中记录的id,它应该是简单的一对一关系,但opciones作为一个实体在其他实体中被多次实例化。问题是,在DB中,TipoClientId没有列,有一列确实包含一个int的Id,但不知道如何映射到ef中的实体。如果我感到困惑,请告诉我。问题是,在DB中,TipoClientId没有列,有一列确实包含Id,这是一个int,但不知道如何映射到ef中的我的实体。如果我感到困惑,请告诉我。