可以这样操作Xml

Xml Data Source

simple xml data source to be used as a replacement to sql server for a poor

Project Description
The framework will be used for creating easy and simple xml data source to be used as a replacement to sql server for a poor, simple, non-complicated environment. All Access to the data is done via simple sql queries as "select" "insert" "update" and "delete". All queries are executed with simplistic assumptions and best try to return results without any exceptions.

 

[Test]
public void TestCreateTable3()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("create table users (id,firstname)");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Create, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
Assert.IsTrue(command.Fields.Contains(
"id"));
Assert.IsTrue(command.Fields.Contains(
"firstname"));
}

 

DropTable
[Test]
public void TestDropTable1()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("drop table users");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Drop, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
}

 

Insert
[Test]
public void TestInsert2()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("insert into users (id) values (3)");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Insert, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
Assert.IsTrue(command.KeysValues[
"id"] == "3");
}

 

Update
[Test]
public void TestUpdate2()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("Update users set username='tal'");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Update, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
Assert.IsTrue(command.KeysValues[
"username"] == "tal");
}

 

Delete
[Test]
public void TestDelete5()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("delete from users where id='3' and username='tal' and age=31");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Delete, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
Debug.WriteLine(command.Filter[
"id"]);
Assert.IsTrue(command.Filter[
"id"] == "3", "bad filter : id");
Debug.WriteLine(command.Filter[
"username"]);
Assert.IsTrue(command.Filter[
"username"] == "tal", "bad filter : username");
Assert.IsTrue(command.Filter[
"age"] == "31", "bad filter : age");
}

 

Select
[Test]
public void TestSelect4()
{
XmlParsedCommand command
= SqlParserWrapper.ParseCommandBeta("select id,firstname,age from users where id=3");
Assert.IsTrue(command.Type
== XmlParsedCommand.CommandType.Select, "command type");
Assert.IsTrue(command.TableName
== "users", "table name");
Assert.IsTrue(command.Fields.Contains(
"id"));
Assert.IsTrue(command.Fields.Contains(
"firstname"));
Assert.IsTrue(command.Fields.Contains(
"age"));
Assert.IsTrue(command.Filter[
"id"] == "3");
}

 

 

 

 

 

 

 

 

http://www.codeplex.com/XmlData

转载于:https://www.cnblogs.com/wt0731/archive/2008/11/20/1337572.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值