xml Document not called propertychanged
-
segunda-feira, 5 de março de 2012 09:43
Hello there I am new to xml and this is my first project working on xml files so needs bit help of yours
Data Layer
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_InputDataXML", DbType="Xml", UpdateCheck=UpdateCheck.Never)]
public System.Xml.Linq.XDocument InputDataXML
{
get
{
return this._InputDataXML;
}
set
{
if ((this._InputDataXML != value))
{
this.OnInputDataXMLChanging(value);
this.SendPropertyChanging();
this._InputDataXML = value;
this.SendPropertyChanged("InputDataXML");
this.OnInputDataXMLChanged();
}
}
}MV
private XDocument _xmlDoc;
private StudyConfig _studyConfigData;
private XElement _parent;
private XElement _xElement;
void SetStudyConfigData ()
{
try
{
_studyConfigData = (from sc in _studyDataContext.StudyConfigs
where sc.SiteId == SiteId && sc.StudyId == StudyId
select sc).Single<StudyConfig>();
}
catch (Exception ex)
{
}
finally
{
if (_studyConfigData == null)
{
_studyConfigData = new StudyConfig();
_xmlDoc = new XDocument();
_parent = new XElement("Parent");
_xmlDoc.Add(_parent);
_dataExists = false;
_studyConfigData.InputDataXML = _xmlDoc;
}
else
{
_xmlDoc = _studyConfigData.InputDataXML;
_dataExists = true;
_studyConfigData.InputDataXML = null;
// _studyDataContext.ExecuteCommand("UPDATE StudyConfig SET inputDataXML = NULL WHERE Id =" + _studyConfigData.Id);}
}
}public void AddElement(XElement Element)
{
SetStudyConfigData();
_xmlDoc.Element("Parent").Add(Element);
_studyConfigData.InputDataXML = _xmlDoc;
// _parent.Add(Element);
// _xmlDoc.Add(Element);
}At this point _xmlDoc =’ <Parent>
<sample_Recieved number_of_itme="Int" date="DateTime" />
</Parent>’
And Element = ‘<sample_Recieved_Second number_of_itme="Int" date="DateTime" />’
So at the end of the function _xmlDoc =
’ <Parent>
<sample_Recieved number_of_itme="Int" date="DateTime" />
<sample_Recieved_Second number_of_itme="Int" date="DateTime" />
</Parent>’
Its all looks goodpublic void Save()
{
try
{
if (!_dataExists)
{
_studyDataContext.StudyConfigs.InsertOnSubmit(_studyConfigData);
}
_studyDataContext.SubmitChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}When I call save(); the change is not effecting the database
Any help would be appreciated

