I have looked at lots of demos / tutorials / docs and examples but I still do not know what approach to take for data access from a SL app embeded in an existing ASP.NET WebSite using LinqToSQL with table hadler classes. There seems to be multiple ways to create and access the service.
It seems that adding a "Domain Service" to the WebSite is the way to go because the SL app gets generated code that code has a copy of the LinqToSQL row classes for each table.
The RadGridView is supposed to be able to access the service and only transfer the visible data from the server.
I have not been able to succesfully bind the RadGridView.
Here is what I have:
WebSite - The ASP.NET site that contains a generated page that contains the SL app.
DataHandler - a project containing the LinqToSql dbml and other data access classes.
SL - the SL app that gets the generated code for the service.
The solution compliles fine and the SL Generated_Code folder gets the WebSite.g.cs file generated OK.
WebSite.g.cs contains:
namespace SL, class WebContext : WebContextBase
namespace WebSite.Services, class DS : DomainContext containing:
Constructors, methods returning InvokeOperation, a interface IDSContract with BeginGet... and EndGet methods, a DSEntityContainer : EntityContainer class.
namespace DataHander, class TableRow : ComplexObject (a dbml class copy)
WebSite/Services/DS.cs:
[EnableClientAccess()] public class DS : DomainService { public IEnumerable<TableRow> GetTableRows() { TableRowHandler H = new TableRowHandler(); return H.GetRecords(); } }The above is the custom code I added to query the records. I used this code because we use table handler classes that use a context factory. I can create and access the context in code, but it is not something I can specify in xaml or as a property.
The RadGridView needs an ItemSource for binding and I do not know what to supply.
I do not understand the DomainContext setting for the DomainDataSource.
Most examples use NorthwindDataContext or something similar.
I would think that the SL generated code class DS : DomainContext should be used, but I do not know how to access/reference it.
<UserControl x:Class="SL.MainPage" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" > <Grid x:Name="LayoutRoot"> <riaControls:DomainDataSource Name="DS" QueryName="GetTableRows" FilterOperator="Or" AutoLoad="True" LoadedData="DS_LoadedData" > <riaControls:DomainDataSource.DomainContext> <"!!!WHAT DO I PUT HERE?!!!" /> </riaControls:DomainDataSource.DomainContext> </riaControls:DomainDataSource> <telerik:RadGridView Name="RGV" IsReadOnly="True" ItemsSource="{Binding Data, ElementName=DS}"> </Grid> </UserControl> I bet this is very simple, but I have not found the answer anywhere.
I wanted to put DS for "!!!WHAT DO I PUT HERE!!!", but that is invalid. I tried adding a clr-namespace reference above and using namespace:DS, but that was unrecognized also.
Is it supposed to be some DomainContext from the WebSite? How can that work?
I would appreciate any guidance available.
Thanks.