SubSonic直接执行SQL语句可以使用以下方式:

	public void Inline_Simple()
	{
		QueryCommand cmd = new InlineQuery().GetCommand("SELECT productID from products");
		Assert.IsTrue(cmd.CommandSql == 
                "SELECT productID from products");
	}
 
	public void Inline_WithCommands()
	{
		QueryCommand cmd = new InlineQuery()
               .GetCommand(@"SELECT productID from products 
                   WHERE productid=@productid", 1);
 
		Assert.IsTrue(cmd.Parameters[0].ParameterName == "@productid");
		Assert.IsTrue((int)cmd.Parameters[0].ParameterValue == 1);
	}
 
	public void Inline_AsCollection()
	{
		ProductCollection products =
			new InlineQuery()
				.ExecuteAsCollection<ProductCollection>(
                          @"SELECT productID from products 
                           WHERE productid=@productid", 1);
	}

注意:可能需要指定DataProvider,在应用中可能需要session的支持。

相关文章:

  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-11-03
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2021-08-10
  • 2021-12-08
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案