Using Typed Views
For Entity Framework v5 and v6, LLBLGen Pro supports Typed View definitions mapped onto a table valued function resultset or a stored procedure resultset. Below the code resulting from these two mapping types are described.
Typed View mapped onto a Table Valued Function
See for more information about a Typed View mapped onto a Table Valued Function Using Table Valued Functions.
Typed View mapped onto a Stored Procedure Resultset
You can map a Typed View on a single resultset, and the stored procedure returning the resultset can only return a single resultset as well, multiple resultset returning stored procedures aren't supported.
In the generated context class, a method is generated for every typed view definition mapped onto a stored procedure resultset, with the name GetTypedViewNameTypedView. The method has a parameter for every stored procedure parameter, equal to the call methods for normal stored procedure calls. The typed view fetch method returns an ObjectResult<TypedViewNameTypedViewRow> object.
In the example below a typed view, called CustomerOrderOrdersResult is mapped onto the resultset of the stored procedure CustOrderOrders of the Northwind database.
var ctxt = new NorthwindDataContext();
var typedViewRows = ctxt.GetCustomerOrderOrdersResultTypedView("ALFKI");
The following remark is important for users who have Typed Views mapped onto stored procedure resultsets (Entity Framework v6+)
The issue with the output parameters as documented here: https://entityframework.codeplex.com/workitem/1991 is still present by default: it occurs if the return type of the method is ObjectResult, which is the default. The cause is that Entity Framework always fetches the resultset as a stream, not as a buffered resultset.
This causes the parameters to be populated after the method ends as only then the result is enumerated. We don't want to change the result type to something like List by default because the issue is really a bug in EF: there's no way to specify that the query should return a buffered resultset, it always streams, at least on SQL Server.
This means that to fix the problem either the EF team has to add a single Read() call to the internals or that we make a setting to allow the user to specify the method return type. We have decided not to wait for EF to have this bug fixed (as they have said they won't fix it), so we added the workaround: for every typed view which is mapped onto a stored procedure which also returns output parameters, the setting ReturnTypeOfFetchMethod (which is defined on the typed view, in its code generation info tab) has to be set to List.
This can be done in bulk by either using the default setting ReturnTypeOfTypedViewOnStoredProcCallDefault on the Project Settings / Entity Framework 6 section (which affects all typed views), or by using the Bulk Element Setting Manipulator tool in the designer to set the ReturnTypeOfFetchMethod setting for several typed views in one go.