Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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
Entity framework 使用Context.Database.SqlQuery执行存储过程<;T>;和复杂类型映射_Entity Framework_Stored Procedures_Mapping_Ef Code First_Complextype - Fatal编程技术网

Entity framework 使用Context.Database.SqlQuery执行存储过程<;T>;和复杂类型映射

Entity framework 使用Context.Database.SqlQuery执行存储过程<;T>;和复杂类型映射,entity-framework,stored-procedures,mapping,ef-code-first,complextype,Entity Framework,Stored Procedures,Mapping,Ef Code First,Complextype,我有一个名为Product的类,其结构如下: public class Product { public long Id { get; set; } public string Title { get; set; } public string Summary { get; set; } public string Description { get; set; } public long ProductCategoryId { get

我有一个名为Product的类,其结构如下:

    public class Product
  {
    public long Id { get; set; }

    public string Title { get; set; }

    public string Summary { get; set; }

    public string Description { get; set; }

    public long ProductCategoryId { get; set; }

    public virtual ProductCategory ProductCategory { get; set; }

    public ConstantPost ConstantPost { get; set; }

  }
有一种称为ConstantPost的复杂类型。 当我想执行一个名为mostbound的存储过程时,会出现以下错误:
无法为类型为“Domain.ConstantPost”的属性“ConstantPost”创建值。仅支持具有基元类型的属性。

如何在执行存储过程时忽略复杂类型


提前感谢。

目前不支持此操作。您不能从
SqlQuery
返回包含复杂类型的实体,谢谢。我想我应该创建另一个模型来检索我的数据。我简直不敢相信这是不受支持的。这似乎是一种相对常见的数据存储方式。存储、更新和删除数据与适当的
ModelBuilder
信息完美配合,因此我不确定自己是否理解为什么使用完全相同格式的存储过程拉回数据会导致此错误。除了编写冗余模型之外,没有其他方法可以解决这个问题了?@Eric:尝试在
DbSet
实例上使用
SqlQuery
。@LadislavMrnka,你能详细说明一下吗?@LadislavMrnka,你能详细说明一下吗?直接在
DbSet
实例上调用
SqlQuery
会产生相同的错误。