你如何映射一个实体

你如何映射一个实体

本文介绍了你如何映射一个实体 - >使用Fluent NHibernate的界面关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定以下类定义:

  C>。 (注意,我不是在讨论映射类 Order 的 Product 字段。)


given the following class definition:

public class Order {
  public IProduct Product {get;set;}
}

I have this (fluent) mapping

References(x=>x.Product, "ProductId");

And get this exception: An association from the table Orders refers to an unmapped class, which makes sense because it doesn't know what implementation I will pass to it.

I understand why I have to define the type in the mapping (IProduct could be anything) but I'm not sure how to do it.

Thanks,

Kyle

解决方案

Try mapping the interface IProduct instead of the concrete class Product. (Note, I'm not talking about mapping the Product field of class Order.)

这篇关于你如何映射一个实体 - >使用Fluent NHibernate的界面关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 01:50