SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 372 | Next

Scott Klein

"Professional LINQ"

One statement returns four columns,
the other returns three columns.
CREATE PROCEDURE [dbo].[ContactsOrProducts]
(
@whichone int
)
AS
BEGIN
if @whichone = 1
SELECT ContactID, Title, FirstName, LastName FROM Person.Contact
else
SELECT ProductID, Name, ProductNumber FROM Production.Product
END
GO
As you did earlier, you create a mapping to that stored procedure and the associated parameters. In
Visual Studio, add the following code below the previous stored procedure mapping. In this code, two
result types are defined as well as the parameter that will be passed to the stored procedure.
[Function(Name = "[ContactsOrProducts]")]
[ResultType(typeof(ContactsPart))]
[ResultType(typeof(ProductsPart))]
235
Part III: LINQ to SQL
public IMultipleResults whichone(
[Parameter(DBType = "int")] System.Nullable whichone)
{
return this.ExecuteMethodCallWithMultipleResults(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())), whichone);
}
The two result types, called ContactsPart and ProductsPart, identify the table mapping for the incoming
results.


Pages:
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6