How to use DomainService with dynamic data?

Last post 07-07-2009 9:09 AM by sjnaughton. 6 replies.

Sort Posts:

  • How to use DomainService with dynamic data?

    07-03-2009, 8:19 AM
    • Member
      3 point Member
    • yashgt
    • Member since 08-09-2007, 3:22 PM
    • Posts 23

    Hi,

    I have followed the steps described at "Using a DomainService in ASP.NET and Dynamic Data"(http://blogs.msdn.com/davidebb/archive/2009/03/24/using-domaindatasource-in-asp-net.aspx) using ASP.NET Dynamic Data 4.0 Preview 4.
    The Domain Service looks like this:
    public class DomainService1 : LinqToEntitiesDomainService<AdventureWorksEntities1>
        {

            // TODO: Consider
            // 1. Adding parameters to this method and constraining returned results, and/or
            // 2. Adding query methods taking different parameters.
            public IQueryable<Employee> GetEmployee()
            {
                return this.Context.Employee;
            }

            // TODO: Consider
            // 1. Adding parameters to this method and constraining returned results, and/or
            // 2. Adding query methods taking different parameters.
            public IQueryable<Product> GetProduct()
            {
                return this.Context.Product;
            }
        }

    When I access Employee/List.aspx in the dynamic data website, I get the error that says:
    Could not find a property or field called 'Employee' on the data context type 'DomainService1' of LinqDataSource 'GridDataSource'.

    What do I need to resolve this? Any suggestions?

    Thanks,
    Yash

  • Re: How to use DomainService with dynamic data?

    07-04-2009, 8:23 AM
    • Star
      12,262 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,559
    • TrustedFriends-MVPs

     Hi Yashgt, have you looked at the latest release of Preview 4 see: Dynamic Data Preview 4 (REFRESH) 
    by scothu which has some fixes for DomainService.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: How to use DomainService with dynamic data?

    07-06-2009, 2:55 AM
    • Member
      3 point Member
    • yashgt
    • Member since 08-09-2007, 3:22 PM
    • Posts 23

    Instead on LinqToSqlDataSource I have:

       <asp:DomainDataSource ID="GridDataSource1" runat="server" EnableDelete="true">
      <WhereParameters>
      <asp:DynamicControlParameter ControlID="FilterRepeater" />
      </WhereParameters>
      </asp:DomainDataSource>

    Using the REFRESH DynamicData preview 4 did not help. At this line:

    table = GridDataSource1.GetTable();

    It gives an error saying : table expects IDynamicDataSource and we are assigning DomainDataSource.

    I tried:GridDataSource1.TryGetMetaTable(out table);

    But the table turns out to be null.

  • Re: How to use DomainService with dynamic data?

    07-06-2009, 4:39 AM
    • Star
      12,262 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,559
    • TrustedFriends-MVPs

    yashgt:

    It gives an error saying : table expects IDynamicDataSource and we are assigning DomainDataSource.

     

    I've had this error with Linq to SQL and EF and it is usually to do with not setting something i.e. the gridview does not point to the DataSource etc.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: How to use DomainService with dynamic data?

    07-06-2009, 12:07 PM
    • Contributor
      2,190 point Contributor
    • davidfowl
    • Member since 08-17-2008, 5:50 PM
    • Redmond
    • Posts 450
    • AspNetTeam
      Moderator

    Looks like your using the wrong page templates. In preview 4 there is the ProjectTemplates/DomianServiceProject  can you confirm that you are using the right page templates? The new templates do not use the datasource's WhereParameters...

    David Fowler
    SDE, ASP.NET Team, Microsoft
  • Re: How to use DomainService with dynamic data?

    07-07-2009, 6:07 AM
    • Member
      3 point Member
    • yashgt
    • Member since 08-09-2007, 3:22 PM
    • Posts 23

     It worked after I used the new templates. However, I had to change the DomainService to get it working as described at http://forums.asp.net/t/1443397.aspx

    The UpdateEntity function is expected to take a single param, whereas the DomainService is created by default with 2 params.

    I think the DynamicData team should work to resolve this.

     

    Thanks,

    Yash

  • Re: How to use DomainService with dynamic data?

    07-07-2009, 9:09 AM
    • Star
      12,262 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,559
    • TrustedFriends-MVPs

     Hi Yashgt, it's worth noting that the ASP.Net Team do read this forum and provide answers, so your point will be noted Smile also DomainService stuff is owned by the Silverlight team see here for there .NET RIA Services forum.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
Page 1 of 1 (7 items)