Skip to content

Update 2009-04-03-inline_query_tool.markdown #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions _posts/2009-04-03-inline_query_tool.markdown
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
---
layout: post
title: "Inline Query Tool"
---

# Inline Query Tool

Sometimes there's just no way an ORM can do what you want it to do, and I completely recognize this. It's just not a good idea to try to use your ORM for everything - and it's why I always say "SubSonic isn't really an ORM - it's a query tool". Given that, we want to give you a back door, and in honor of Jeff Atwood we created the Inline Query tool. Go ahead - no one's looking... do your job and be proud of it.public void Inline_Simple() { QueryCommand cmd = new InlineQuery().GetCommand("SELECT productID from products"); Assert.IsTrue(cmd.CommandSql

<h2> "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 </h2>

1); } public void Inline_AsCollection() { ProductCollection products = new InlineQuery() .ExecuteAsCollection<ProductCollection>( @"SELECT productID from products WHERE productid=@productid", 1); }
---
layout: post
title: "Inline Query Tool"
---

# Inline Query Tool #

Sometimes there's just no way an ORM can do what you want it to do, and I completely recognize this. It's just not a good idea to try to use your ORM for everything - and it's why I always say "SubSonic isn't really an ORM - it's a query tool". Given that, we want to give you a back door, and in honor of Jeff Atwood we created the Inline Query tool.
Go ahead - no one's looking... do your job and be proud of it.

## Examples ##


__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);
}