I'm trying to create my first DomainDataSource and have followed the steps in the video at:
http://tv.telerik.com/watch/silverlight/getting-started-with-raddomaindatasource
(very helpful!)
However, I am uncertain where I get the name for the source of my DomainContext.
The example uses the TestDomainServices.CS and in the code of the application it uses
<telerik:RadDomainDataSource.DomainContext>
<service:TestDomainContext />
</telerik:RadDomainDataSource.DomainContext>
------
So I created a NorthDomainService.CS and used:
<telerik:RadDomainDataSource.DomainContext>
<source:NorthDomainContext />
</telerik:RadDomainDataSource.DomainContext>
But I get the following error message:
Error 1 The type 'service:NorthDomainContext' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
What am I missing or where do I get the correct data for the <source:.../>
Thanks,
Rebecca
8 Answers, 1 is accepted
Do you get this with both standard DomainDataSource and RadDomainDataSource or this is just related to RadDomainDataSource?
Kind regards,Vlad
the Telerik team
Thanks for the reply. I am only trying it with the RadDomainDataSouce. Is it possible that I'm missing a reference?
Thanks,
Rebecca
You need to add a xml namespace for the generated classes, i.e. the domain context. You should find your generated domain context class and see under what namespace it is. This namespace should be included on your page so that the domain context can be found.
namespace
SilverlightApplication1.Web.Services
{
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.ComponentModel.DataAnnotations;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.ServiceModel.DomainServices;
using
System.ServiceModel.DomainServices.Client;
using
System.ServiceModel.DomainServices.Client.ApplicationServices;
using
System.ServiceModel.Web;
using
SilverlightApplication1.Web.Models;
/// <summary>
/// The 'DistinctValue' entity class.
/// </summary>
[DataContract(Namespace=
"http://schemas.datacontract.org/2004/07/SilverlightApplication1.Web.Services"
)]
public
sealed
partial
class
DistinctValue : Entity
{
private
int
_id;
private
string
_value;
#region Extensibility Method Definitions
/// <summary>
/// This method is invoked from the constructor once initialization is complete and
/// can be used for further object setup.
/// </summary>
partial
void
OnCreated();
partial
void
OnIDChanging(
int
value);
partial
void
OnIDChanged();
partial
void
OnValueChanging(
string
value);
partial
void
OnValueChanged();
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="DistinctValue"/> class.
/// </summary>
public
DistinctValue()
{
this
.OnCreated();
}
/// <summary>
/// Gets or sets the 'ID' value.
/// </summary>
[DataMember()]
[Editable(
false
, AllowInitialValue=
true
)]
[Key()]
[RoundtripOriginal()]
public
int
ID
{
get
{
return
this
._id;
}
set
{
if
((
this
._id != value))
{
this
.OnIDChanging(value);
this
.ValidateProperty(
"ID"
, value);
this
._id = value;
this
.RaisePropertyChanged(
"ID"
);
this
.OnIDChanged();
}
}
}
/// <summary>
/// Gets or sets the 'Value' value.
/// </summary>
[DataMember()]
public
string
Value
{
get
{
return
this
._value;
}
set
{
if
((
this
._value != value))
{
this
.OnValueChanging(value);
this
.RaiseDataMemberChanging(
"Value"
);
this
.ValidateProperty(
"Value"
, value);
this
._value = value;
this
.RaiseDataMemberChanged(
"Value"
);
this
.OnValueChanged();
}
}
}
/// <summary>
/// Computes a value from the key fields that uniquely identifies this entity instance.
/// </summary>
/// <returns>An object instance that uniquely identifies this entity instance.</returns>
public
override
object
GetIdentity()
{
return
this
._id;
}
}
/// <summary>
/// The DomainContext corresponding to the 'NorthwindDomainService' DomainService.
/// </summary>
public
sealed
partial
class
NorthwindDomainContext : DomainContext
{
<
UserControl
x:Class
=
"SilverlightApplication1.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:e
=
"clr-namespace:SilverlightApplication1.Web.Services"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"200"
/>
</
Grid.RowDefinitions
>
<
telerik:RadDomainDataSource
x:Name
=
"customersDataSource"
AutoLoad
=
"True"
QueryName
=
"GetCustomersByCountry"
PageSize
=
"10"
LoadDelay
=
"0:0:1.0"
LoadingData
=
"OnCustomersDataSourceLoadingData"
LoadedData
=
"OnCustomersDataSourceLoadedData"
>
<
telerik:RadDomainDataSource.QueryParameters
>
<
telerik:QueryParameter
ParameterName
=
"country"
Value
=
"{Binding Text, ElementName=countryTextBox}"
/>
</
telerik:RadDomainDataSource.QueryParameters
>
<
telerik:RadDomainDataSource.DomainContext
>
<
e:NorthwindDomainContext
/>
</
telerik:RadDomainDataSource.DomainContext
>
</
telerik:RadDomainDataSource
>
<
telerik:RadDomainDataSource
x:Name
=
"distinctValuesDataSource"
AutoLoad
=
"False"
QueryName
=
"GetDistinctValues"
LoadingData
=
"OnDistinctValuesDataSourceLoadingData"
LoadedData
=
"OnDistinctValuesDataSourceLoadedData"
>
<
telerik:RadDomainDataSource.DomainContext
>
<
e:NorthwindDomainContext
/>
</
telerik:RadDomainDataSource.DomainContext
>
<
telerik:RadDomainDataSource.QueryParameters
>
<
telerik:QueryParameter
ParameterName
=
"propertyName"
/>
</
telerik:RadDomainDataSource.QueryParameters
>
</
telerik:RadDomainDataSource
>
<
telerik:RadGridView
x:Name
=
"radGridView"
Grid.Row
=
"0"
ItemsSource
=
"{Binding DataView, ElementName=customersDataSource}"
IsBusy
=
"{Binding IsBusy, ElementName=customersDataSource}"
DistinctValuesLoading
=
"OnRadGridViewDistinctValuesLoading"
ShowGroupPanel
=
"False"
IsReadOnly
=
"True"
/>
<
telerik:RadDataPager
x:Name
=
"radDataPager"
Grid.Row
=
"1"
Source
=
"{Binding DataView, ElementName=customersDataSource}"
DisplayMode
=
"All"
IsTotalItemCountFixed
=
"True"
/>
<
StackPanel
Name
=
"configPanel"
Grid.Row
=
"2"
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"Country: "
VerticalAlignment
=
"Center"
/>
<
TextBox
Name
=
"countryTextBox"
Width
=
"100"
VerticalAlignment
=
"Center"
/>
</
StackPanel
>
<
ScrollViewer
Grid.Row
=
"3"
x:Name
=
"debugScrollViewer"
>
<
TextBox
x:Name
=
"debugTextBox"
FontSize
=
"12"
HorizontalScrollBarVisibility
=
"Auto"
VerticalScrollBarVisibility
=
"Auto"
TextChanged
=
"OnDebugTextBoxTextChanged"
/>
</
ScrollViewer
>
</
Grid
>
</
UserControl
>
I have attached a sample project for reference. You can examine it to see how to do this. Greetings,
Ross
the Telerik team
I'm getting closer and am able to load and run the sample you sent but I seem to be off when I try it.
It still says:
Error 1 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'Hotel.Web.Services' that is not included in the assembly.
Error 2 The type 'e:phaDomainContext' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
And I included
xmlns:e="clr-namespace:Hotel.Web.Services"
in the header of the mainpage.xaml and my .cs file is in the Services folder.
I've attached a screen capture to show the file structure of the documents. Any help is appreciated!
Rebecca
When you rebuild the entire solution you will get a folder with generated code in the client project. Click the icon to see all hidden items in the client project. You should see a folder containing the generated code. Go there and see what is the name of your DomainContext and the namespace.
Please, read this tutorial very carefully and follow its steps exactly. If you follow this tutorial exactly -- you will have your domain context without any problems.
By the way, it would be better if you post these kinds of questions on the WCF RIA Services forums, since they are not related to Telerik controls in any way. Telerik does not develop and support WCF RIA Services or Visual Studio, so you should contact the appropriate parties when you have problems with these technologies/products.
I hope this makes sense. Thank you for your understanding.
Ross
the Telerik team
I got it! Thanks so much for responding when it wasn't a Telerik issue that I was learning.
As you can tell, I'm not a full-time programmer and Telerik really opens up a lot of opportunities for people like me. Thanks for developing a great program and providing the learning resources.
-Rebecca
I have a problem with RadDomainDataSource.DomainContext. My DomainContext works well with
DomainDataSource, but when i use it in the RadDomainDataSource i will retrive a error like this:
"Can not create an instance of RadDomainDataSource"
Do you have any idea for this ?