简体   繁体   English

实体框架-如何将属性设置为特殊类型

[英]Entity Framework — How to set properties to special types

I'm new to MVC and Entity Framework, so this may be a relatively simple answer, but I've tried searching around so far and no luck. 我是MVC和Entity Framework的新手,所以这可能是一个相对简单的答案,但是到目前为止,我已经尝试过搜索并且没有运气。

I'm using the most recent versions of both tools to my knowledge (MVC 3 Beta and Entity Framework 4.0) 据我所知,我正在使用这两种工具的最新版本(MVC 3 Beta和Entity Framework 4.0)

I'm just trying to set up a quick example. 我只是想建立一个简单的例子。 Logically, I'm dealing with events -- in this case, an OngoingServiceEvent and a FiniteServiceEvent, which both inherit from ServiceEvent. 从逻辑上讲,我正在处理事件-在这种情况下,都是OngoingServiceEvent和FiniteServiceEvent,它们都继承自ServiceEvent。 I have a Locations Entity, which has LongLatLocation and AddressLocation that inherit from it. 我有一个位置实体,该实体具有从其继承的LongLatLocation和AddressLocation。

I would like to specify a location in ServiceEvent, and have it be of type Location, but the types seem limited to those in the database. 我想在ServiceEvent中指定一个位置,并使其具有Location类型,但该类型似乎仅限于数据库中的类型。

What's the course of action in this scenario? 在这种情况下该怎么办? Is this what I want to do, or am I confused on the implementation of what I want? 这是我想要做的,还是我对想要执行的事情感到困惑?

Thanks in advance for any help you can give! 在此先感谢您提供的任何帮助!

You're looking for a feature called Complex Types . 您正在寻找一种称为Complex Types的功能。 Best answer I can give is the MSDN documentation. 我能给出的最佳答案是MSDN文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM