In the following example, the highlighted code shows how to implement a stored procedure mapping
into your client object class:
[Table(Name = "Person.Contact")]
public class Contact
207
Part III: LINQ to SQL
{
[Column(DBType = "nvarchar(8) not null")]
public string Title;
[Column(DBType = "nvarchar(50) not null")]
public string FirstName;
[Column(DBType = "nvarchar(50) not null")]
public string MiddleName;
[Column(DBType = "nvarchar(50) not null")]
public string LastName;
[Column(DBType = "nvarchar(50) not null")]
public string EmailAddress;
[Column(DBType = "int")]
public int EmailPromotion;
[StoredProcedure(Name="OrdersBySalesPersonID")]
public IEnumberable OrdersBySalesPersonID([Parameter(DBType =
"int")] String param1)
{
IExecuteResults results = this.ExecuteMethodCall
(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())),
param1);
}
}
You??™ll learn more about LINQ to SQL and stored procedure mapping in Chapter 11.
Mapping Functions
LINQ to SQL also supports user-defined functions. Client objects and user-defined functions are mapped
the same way stored procedures are??”through an attribute.
Pages:
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343