I ‘ve written a Query with Linq and in one part of my code I try to assign string to an XML but an error occured:
Cannot implicitly convert type ‘string’ to ‘System.Xml.Linq.XElement’
This is my code:
public int Save(Route route)
{
aspnetdbDataContext aspdb = new aspnetdbDataContext();
RouteLinq rtlq=new RouteLinq();
rtlq.UserId = route.UserId;
rtlq.SourceName = route.Name;
//I have an error hier
rtlq.GpxData = route.GpxData;
//---------------------------
rtlq.CreationTime = route.Time;
aspdb.RouteLinqs.InsertOnSubmit(rtlq);
aspdb.SubmitChanges();
}
How can I solve my problem?
Because GpxData is of type XML in your database you can’t assign string to it directly, you need to create an en XElement and then assign it the value:
Where
route.GpxDatais of type string