문제

I have this class:

    [Table("Items", Schema = "Datamodel")]
    public class BaseItem : Identifier
    {
        [Required(ErrorMessage = "Name is required.")]
        [MaxLength(240)]
        public string Name { get; set; }

        public XmlDocument Content { get; set; }

        public BaseItem() { Content = new XmlDocument(); }
        internal BaseItem(string name) : this() { Name = name; }
    }
}

(The Identifier class just defines an extra property Id of type GUID, which is required and by default initialized with a new value. All my POCO classes inherit from this one.)

The problem is the XmlDocument property, which I want to be stored within the database, preferably as type XML so the contents of the XML can be part of my queries. So, is that possible?
If not, what would be the best alternative while keeping the public interface of this class intact?

도움이 되었습니까?

해결책

It might be possible to Serialize the XmlDoc as a Blob but why bother? It's essentially text.

public string ContentText { get; set; }

private _xmlDocuent;    
[NotMapped] 
public XmlDocument Content 
{
  get { return _xmlDocumet ?? (_xmlDocument = new XmlDocuent.Parse(ContentTExt)); }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top