private XElement GetClinicalClientPrice(int invid)
{
using (MyDatabase db = new MyDatabase())
{
return new XElement("CLINICALCLIENTPRICE",
from ccp in db.TblClinicalClientPrice
where ccp.INVENTORY_ID == invid
select new XElement("Record",
new XElement("ITEM_ID",ccp.ITEM_ID),
new XElement("INVENTORY_ID", ccp.INVENTORY_ID),
new XElement("ITEM_DESCRIPTION", ccp.ITEM_DESCRIPTION),
new XElement("SUPPLIER_CAT", ccp.SUPPLIER_CAT),
new XElement("NDC_CODE", ccp.NDC_CODE),
new XElement("ITEM_NUMBER", ccp.ITEM_NUMBER),
new XElement("UOM", ccp.UOM),
new XElement("CONVERSION_FACTOR", ccp.CONVERSION_FACTOR),
new XElement("MANUFACTURER", ccp.MANUFACTURER),
new XElement("SESSION_ID", ccp.SESSION_ID),
new XElement("USERNAME", ccp.USERNAME),
new XElement("ENTRY_TIME", ccp.ENTRY_TIME),
new XElement("COST", ccp.COST),
new XElement("CLIENT_INPUT_ID", ccp.CLIENT_INPUT_ID),
new XElement("MHS_ITEM_ID", ccp.MHS_ITEM_ID),
new XElement("GUID", ccp.GUID),
new XElement("UNIQUE_ID", ccp.UNIQUE_ID),
new XElement("SUPPLIER_CAT_MODIFIED", ccp.SUPPLIER_CAT_MODIFIED),
new XElement("SIZE", ccp.SIZE),
new XElement("STRENGTH", ccp.STRENGTH)
));
}
}
当我将上面生成的XElement插入数据库时,我得到(DateTime)空值异常。 我的例子是:stackoverflow.com/a/21163312/3121707