Prev | Current Page 178 | Next

Satheesh, N Kumar

"LINQ Quickly"

The function uses an
LINQ to SQL
[ 112 ]
ExecuteMethodCall execution method, which actually takes care of executing the
stored procedure. There is a MethodInfo class that executes the stored procedure
using the GetCurrentMethod method, by passing the parameter to the stored
procedure. The result which is of type IExecuteResult has a property RetunValue
that actually returns the value returned by the stored procedure.
The above method GetNumberofItemsforCategory, should be a part of the
DataContext entity class. The DataContext class will look like the this:
[Database(Name = "Deserts")]
public class Deserts : DataContext
{
public Table Categories;
public Table Items;
public Deserts(string connection) : base(connection) { }
[Function(Name = "dbo.GetNumberofItemsforCategory")]
public int GetNumberofItemsforCategory([Parameter(DbType =
"NVarChar(50)")] string category)
{
IExecuteResult result = this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())), category);
return ((int)(result.


Pages:
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
szkolenia dla przedsiębiorców oferty spa Wczasy nad morzem projektowanie wnętrz opony michelin