XML data type in EF 4.1 Code First

前端 未结 3 1561
陌清茗
陌清茗 2021-02-05 17:35

I would like to use SQL Server xml type as a column type for an entity class.

According to this thread it\'s possible to map such a column to st

3条回答
  •  余生分开走
    2021-02-05 18:13

    Just to be complete. Here's all code needed, in one part.

    [Column(TypeName = "xml")]
    public String XmlContent { get; set; }
    
    [NotMapped]
    public XElement InitializedXmlContent
    {
        get { return XElement.Parse(XmlContent); }
        set { XmlContent = value.ToString(); }
    }
    

提交回复
热议问题