This is a migrated thread and some comments may be shown as answers.

Issue with DomainContext

8 Answers 187 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Rebecca
Top achievements
Rank 1
Rebecca asked on 22 Mar 2011, 06:04 AM
Hello,
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

Sort by
0
Vlad
Telerik team
answered on 22 Mar 2011, 08:31 AM
Hi,

Do you get this with both standard DomainDataSource and RadDomainDataSource or this is just related to RadDomainDataSource?

Kind regards,
Vlad
the Telerik team
0
Rebecca
Top achievements
Rank 1
answered on 22 Mar 2011, 02:25 PM
Hi Vlad,

Thanks for the reply.  I am only trying it with the RadDomainDataSouce.  Is it possible that I'm missing a reference?

Thanks,
Rebecca
0
Rossen Hristov
Telerik team
answered on 22 Mar 2011, 02:41 PM
Hello 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>
    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: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
0
Rebecca
Top achievements
Rank 1
answered on 22 Mar 2011, 06:38 PM
Hello,

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

0
Accepted
Rossen Hristov
Telerik team
answered on 23 Mar 2011, 10:00 AM
Hi 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.

Kind regards,
Ross
the Telerik team
0
Rebecca
Top achievements
Rank 1
answered on 23 Mar 2011, 02:21 PM
Hello,

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
0
tony
Top achievements
Rank 1
answered on 19 Jun 2012, 03:36 AM
comment removed
0
Tingting
Top achievements
Rank 1
answered on 19 Nov 2012, 04:07 PM
Hello, 

   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 ? 
 




  
Tags
DomainDataSource
Asked by
Rebecca
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rebecca
Top achievements
Rank 1
Rossen Hristov
Telerik team
tony
Top achievements
Rank 1
Tingting
Top achievements
Rank 1
Share this question
or