Scott Klein
"Professional LINQ"
ExecuteMethodCall
(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())),
salesPersonID);
}
}
229
Part III: LINQ to SQL
There??™s just a little more work to do. You need to map a stored procedure because you need to
map the resultset coming in. In LINQ to SQL, the resultsets for a stored procedure, view, and user-defined
function are in the same form, basically in table format. Thus, you can map the stored procedure resultset
to a class tagged as a table.
As shown in the following highlighted code, add a partial class with the name OrdersBySales-
PersonID, and add the Table attribute. Within the attribute, pass the name of the stored procedure that
will be called.
namespace LINQ
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
public class AdventureWorks : DataContext
{
public AdventureWorks(string connection) : base(connection) {}
[Function(Name = "OrdersBySalesPersonID")]
public IEnumerable SalesOrders
([Parameter(DBType="int")] int salesPersonID)
{
return this.
Pages:
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376