Custom Entity And XElement Convertion
来源:互联网 发布:w500安装mac 编辑:程序博客网 时间:2024/04/29 22:13
Custom Entity And XElement Convertion
Custom Entity to XElement
private XElement WorkItemToElement(Entity.Business.WorkItem item) { return new XElement("workItem", new XElement("desc", item.Desc), new XAttribute("id", item.Id), new XAttribute("name", item.Name), new XAttribute("workType", EnumHelper.GetEnumNameFrom(item.WorkType)), new XAttribute("createDate", item.CreateDate), new XAttribute("isFinished", item.IsFinished ? Boolean.TrueString : Boolean.FalseString)); }
XElement To Custom Entity
private Entity.Business.WorkItem ElementToWorkItem(XElement element) { WorkItemType workType; if (!Enum.TryParse(element.Attribute("workType").Value, out workType)) return null; var xElement = element.Element("desc"); var strDesc = string.Empty; if (xElement != null) strDesc = xElement.Value; return new Entity.Business.WorkItem { Id = new Guid(element.Attribute("id").Value), Name = element.Attribute("name").Value, CreateDate = DateTime.Parse(element.Attribute("createDate").Value), Desc = strDesc, WorkType = workType, IsFinished = bool.Parse(element.Attribute("isFinished").Value) }; }
- Custom Entity And XElement Convertion
- Convert XElement to XmlNode (and Convert XmlNode to XElement){转载}
- Convertion between string and int in C++
- RGB "Bayer" Color and MicroLenses, convertion between RGB and YUV
- custom textures and Shapes
- Attributes and custom properties
- XElement类
- ZigZag Convertion
- Time Convertion
- Entity and Attribute Mapping
- Entity states and SaveChanges
- User controls and custom controls
- Custom Models and Dynamic Trees
- Custom Controls and User Controls
- Knockoutjs:Component and Custom Elements
- Entity Framework Code First (二)Custom Conventions
- Entity Framework Code First (二)Custom Conventions
- XDocument 与XElement 区别
- 软件升级遇到的问题
- 米球开博啦!!回忆,奋斗,展望!
- ubuntu12.04的gedit中文乱码
- SQLSERVER和ORACLE 空值排序
- hdu 4790 Just Random 数论
- Custom Entity And XElement Convertion
- JAVA one2Many Many2one Many2Many
- C -- 字符串和字符串函数
- Xml Operation Class Summary
- oracle之动态sql、游标
- 50个c/c++源代码网站
- java反射机制的实现原理
- 数据库获取当前时间
- HDU 4770 Lights Against Dudely 解题报告