2006-12-15

sql2005的xml字段类型在.net中的应用

来源: 本站收集整理 作者:佚名 评论 0 条
 
m.AddSql(xmlStr);
m.AddSql("' where ServerID=");
m.AddSql(_ServerID.ToString());
m.ExecuteNonQuery(conn);
}
}
#endregion

#region 添加服务器对应的店铺信息 void AddMServerShop(int _ServerID, MServerShop _ServerShop)
/// <summary>
/// 添加服务器对应的店铺信息
/// </summary>
/// <param name="_ServerID">服务器的ServerID</param>
/// <param name="_ServerShop">服务器对应的店铺信息</param>
public void AddMServerShop(int _ServerID, MServerShop _ServerShop)
{
//update ES_Server set ServerShops.modify('declare namespace mi="http://www.linkedu.com.cn/MServerShop.xsd"; insert (<mi:Shop ShopID="3" ShopName="hopName3" />) as first into (//mi:Shops)[1]') where ServerID=1
//SELECT ServerID FROM ES_Server WHERE ServerID=1 and ServerShops.exist('declare namespace mi="http://www.linkedu.com.cn/MServerShop.xsd"; //mi:Shops/mi:Shop[@ShopID=4]')=1
//select ServerShops.value('declare namespace mi="http://www.linkedu.com.cn/MServerShop.xsd"; (//mi:Shops/mi:Shop/@ShopID)[1]=4', 'bit') as ShopID from ES_Server where ServerID=1 if @@rowcount > 0 begin select 1 end
string xmlStr = Common.Utilities.SerializationHelper<MServerShop>.ToXML(_ServerShop, "mi");
DataProvider dp = SqlTools.HelpWWW.DataProviderUse;
using (IDbConnection conn = dp.GetConnection())
{
Common.DataAccess.ORMapping.IConvert ic = dp.GetIConvert();
Common.DataAccess.ORMapping.Mapping m = ic.GetNewMapping();
m.AddSql("SELECT ServerID FROM ES_Server WHERE ServerID=" _ServerID.ToString());
m.AddSql(" and ServerShops.exist('declare namespace mi=\"http://www.linkedu.com.cn/MServerShop.xsd\"; //mi:Shops/mi:Shop[@ShopID=" _ServerShop.ShopID.ToString() "]')=1");
m.AddSql(" if @@rowcount = 0 begin ");
m.AddSql("update ES_Server set ServerShops.modify('declare namespace mi=\"http://www.linkedu.com.cn/MServerShop.xsd\"; insert (");
m.AddSql(xmlStr);
m.AddSql(") as first into (//mi:Shops)[1]') where ServerID=" _ServerID.ToString() " end");
m.ExecuteNonQuery(conn);
}
}
#endregion

#region 删除服务器对应的店铺信息 void DeleteMServerShop(int _ServerID, int _ShopID)
/// <summary>
/// 删除服务器对应的店铺信息
/// </summary>
/// <param name="_ServerID">服务器的ServerID</param>
共12页: 上一页 [1] [2] [3] [4] [5] [6] [7] 8 [9] [10] [11] [12] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:SQL Server 2005与DB2 8.2对比分析  
下一篇:SQL Server2005发布元年 微软正身企业级应用
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号