我想在EF Code First中映射Microsoft结构。我的第一个解决方案是创建该结构的模型类,以及将模型转换为Microsoft类的方法(与ViewModels相同的方法)。我的问题是:有没有办法避免创建模型类和方法来将模型类转换为struct?
现在
namespace Microsoft.Kinect
{
public struct Joint
{
public static bool operator !=(Joint joint1, Joint joint2);
public static bool operator ==(Joint joint1, Joint joint2);
public JointType JointType { get; internal set; }
public SkeletonPoint Position { get; set; }
public JointTrackingState TrackingState { get; set; }
public bool Equals(Joint joint);
public override bool Equals(object obj);
public override int GetHashCode();
}
}
namespace Models
{
public class JointModel
{
public JointType JointType { get; set; }
public SkeletonPointModel Position { get; set; }
public JointModel(JointType jointType, SkeletonPointModel position)
{
JointType = jointType;
Position = position;
}
}
}
有没有什么可说的Map struct Joint to table ...我更喜欢只使用一个类,而不必在模型类和结构之间切换。