我是ASP.NET MVC的新手,我想从我的一个类的属性创建一个自定义数据类型。我知道这是可能的,但不幸的是,我缺乏知道我的代码有什么问题的知识。
我收到以下错误消息:
"Schema specified is not valid. Errors:
The relationship 'GarethLewisWeb.Models.Photo_Set' was not loaded because the type
'GarethLewisWeb.Models.Photo' is not available.
The following information may be useful in resolving the previous error:
The property 'Orientation' on the type 'GarethLewisWeb.Models.Photo' has a property
type of 'GarethLewisWeb.Models.Photo+Orientations' which cannot be mapped to a
PrimitiveType."
以下是我认为导致问题的Photo.cs类的代码。
public class Photo
{
public int PhotoID { get; set; }
public int PhotoOrder { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string FileLocation { get; set; }
public Orientations Orientation { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public int Rating { get; set; }
public bool FeaturedPhoto { get; set; }
public enum Orientations
{
Square = 0,
Landscape = 1,
Portrait = 2
}
public virtual Set Set { get; set; }
public virtual PhotoExif PhotoExif { get; set; }
}
任何帮助指定!感谢。
答案 0 :(得分:0)
看看CustomModelBinder,它应该解决你的问题,这里有一篇很好的文章
http://lostechies.com/jimmybogard/2009/03/18/a-better-model-binder/