Created
September 9, 2012 12:31
-
-
Save davybrion/3684087 to your computer and use it in GitHub Desktop.
code snippets for "Populating entities from Stored Procedures with NHibernate"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ALTER PROCEDURE [dbo].[GetProductsByCategoryId] | |
| @CategoryId int | |
| AS | |
| BEGIN | |
| SET NOCOUNT ON; | |
| SELECT [ProductID] | |
| ,[ProductName] | |
| ,[SupplierID] | |
| ,[CategoryID] | |
| ,[QuantityPerUnit] | |
| ,[UnitPrice] | |
| ,[UnitsInStock] | |
| ,[UnitsOnOrder] | |
| ,[ReorderLevel] | |
| ,[Discontinued] | |
| FROM [Northwind].[dbo].[Products] | |
| WHERE [CategoryId] = @CategoryId | |
| END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <sql-query name="GetProductsByCategoryId"> | |
| <return class="Product" /> | |
| exec dbo.GetProductsByCategoryId :CategoryId | |
| </sql-query> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IQuery query = Session.GetNamedQuery("GetProductsByCategoryId"); | |
| query.SetInt32("CategoryId", 1); | |
| IList<Product> products = query.List<Product>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <sql-query name="GetProductsByCategoryId"> | |
| <return class="Product"> | |
| <return-property column="ProductID" name="Id" /> | |
| <return-property column="ProductName" name="Name" /> | |
| <return-property column="SupplierID" name="Supplier" /> | |
| <return-property column="CategoryID" name="Category" /> | |
| <return-property column="QuantityPerUnit" name="QuantityPerUnit" /> | |
| <return-property column="UnitPrice" name="UnitPrice" /> | |
| <return-property column="UnitsInStock" name="UnitsInStock" /> | |
| <return-property column="UnitsOnOrder" name="UnitsOnOrder" /> | |
| <return-property column="ReorderLevel" name="ReorderLevel" /> | |
| <return-property column="Discontinued" name="Discontinued" /> | |
| </return> | |
| exec dbo.GetProductsByCategoryId :CategoryId | |
| </sql-query> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment