Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. CREATE TABLE Workflow
  2. (
  3. Guid uniqueidentifier not null,
  4. State xml not null
  5. )
  6.  
  7. public class Workflow
  8. {
  9. public Guid InstanceId { get;set; }
  10. public XDocument State { get;set; }
  11. }
  12.  
  13. Error parsing column 1 (State= - String)
  14. at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value) in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 4045
  15. at Deserialize038b29f4-d97d-4b62-b45b-786bd7d50e7a(IDataReader )
  16. at Dapper.SqlMapper.<QueryImpl>d__11`1.MoveNext() in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1572
  17. at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
  18. at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
  19. at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1443
  20. at MyProject.DapperBase.Query[TResult](String command, DynamicParameters parameters, IDbTransaction transaction, Boolean buffered, Int32 commandTimeout) in d:\MyProject\DapperBase.cs:line 122
  21. at MyProject.WorkflowData.Get(Guid identifier) in d:\MyProject\WorkflowData.cs:line 41
  22. at MyProject.WorkflowLogic.Save(Workflow workflow) in d:\MyProject\WorkflowLogic.cs:line 34
  23. at MyProject.WorkflowsController.Save(Guid id, WorkflowRequest request) in d:\MyProject\WorkflowsController.cs:line 97
  24.  
  25. InnerException: Invalid cast from 'System.String' to 'System.Xml.Linq.XDocument'.
  26. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
  27. at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
  28. at System.Convert.ChangeType(Object value, Type conversionType)
  29. at Deserialize038b29f4-d97d-4b62-b45b-786bd7d50e7a(IDataReader )
  30.  
  31. public class Workflow
  32. {
  33. public Guid InstanceId { get;set; }
  34. public XDocument StateIn { set { State = value.ToString(); } }
  35. public string State { get;set; }
  36. public XDocument StateOut { get { return XDocument.Parse(State); } }
  37. }
  38.  
  39. public class XDocumentTypeHandler : SqlMapper.TypeHandler<XDocument>
  40. {
  41. public override void SetValue(IDbDataParameter parameter, XDocument value)
  42. {
  43. // set value in db parameter.
  44. }
  45.  
  46. public XDocument Parse(object value)
  47. {
  48. // parse value from db to an XDocument.
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement