locked
Refresh data in HTML client with WCF RIA Service. RRS feed

  • Question

  • Hi all,

    I have a problem with a refresh rate WCF RIA query in the HTML version of Lightswitch . For complex queries use a RIA service to calculate the data to display in the Silverlight client works perfectly but in the HTML client appears that the data is not refreshed when changing the filter.
    I have simplified the problem with an example that I've done in a new project ( I can send it to who wants it ) with the following class:

    namespace RIAService
    {
        public class Usuario
        {
            [Key]
            public int id { get; set; }
            public string UserName { get; set; }
        }
    
        public class WCF_RIA_Service : DomainService
        {        
            [Query(IsDefault = true)]
            public IEnumerable<Usuario> GetUsuarios_default()
            {
                return null;
            }
            
            public IEnumerable<Usuario> GetUsuarios(string filter)
            {
                var r = new Usuario();
                r.id = 1;
    
                if (filter == "1")
                    r.UserName = "Nombre A";
                else if (filter == "2")
                    r.UserName = "Nombre B";
                else
                    r.UserName = "Inicial";
    
                List<Usuario> lista = new List<Usuario>();
                lista.Add(r);
    
                return lista;
            }
    
            // Override the Count method in order for paging to work correctly
            protected override int Count<T>(IQueryable<T> query)
            {
                return query.Count();
            }
        }
    }

    I created a screen shown details see "GetUsuarios " with a filter. When I run the project the result is the following , which is correct:


    But if I change the filter to another value , the table is not refreshed with the new values ​​that gives the WCF service:

    I've debugged step by step WCF service and the values ​​returned are always right, but something happens in the HTML client does not update the table. The same example in the Silverlight client gives the correct result.

    I hope someone can guide me on how to resolve this problem. I use VS2013 with Update 1 RC. Thanks and regards.

    Sunday, December 29, 2013 7:37 PM

Answers

  • Hello,

    If the problem is due to having the same key, LightSwitch understood to be the same data and does not update the table.
    To fix it I can not use your solution because as I said this is an example and in my real query I return a key that corresponds to a particular item and I can not change it.

    To fix it I have set all fields as a key query on the WCF service, and this effort to refresh the table whenever you change any value way:

     public class Usuario
     {
        [Key]
        public int id { get; set; }
        [Key]
        public string UserName { get; set; }
     }


    Friday, January 10, 2014 4:24 PM

All replies

  • RIA services is a server-side technology that automatically generates client-side (Silverlight) objects that take care of the communication with the server for you and provide client-side validation. The main object inside a RIA service is a DomainService, usually a LinqToEntitiesDomainService that is connected to a LinqToEntities model.
    http://www.c-sharpcorner.com/UploadFile/raj1979/how-to-use-wcf-ria-service-in-lightswitch-2012/ .
    Friday, January 3, 2014 10:23 AM
  • Hello,

    The problem is not in the RIA service I use. To do this I used the examples in the page lightswitchhelpwebsite.com.
    The problem is to consume the RIA service from an HTML client, the data is not updated when changing filter parameters.
    Monday, January 6, 2014 4:17 PM
  • I think the problem is that you are reusing the [key].

    1) You pull up a record and it is [1] Nombre A

    2) You do a new filer and return: [1] Nombre B

    3) LightSwitch says "I already have [1] so I am going to show "[1] Nombre A"

    So can you try it with this:

                if (filter == "1")
                    r.id = 1
                    r.UserName = "Nombre A";
                else if (filter == "2")
                    r.id = 2
                    r.UserName = "Nombre B";
                else
                    r.id = 3
                    r.UserName = "Inicial";


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com

    Monday, January 6, 2014 7:34 PM
  • Hello,

    If the problem is due to having the same key, LightSwitch understood to be the same data and does not update the table.
    To fix it I can not use your solution because as I said this is an example and in my real query I return a key that corresponds to a particular item and I can not change it.

    To fix it I have set all fields as a key query on the WCF service, and this effort to refresh the table whenever you change any value way:

     public class Usuario
     {
        [Key]
        public int id { get; set; }
        [Key]
        public string UserName { get; set; }
     }


    Friday, January 10, 2014 4:24 PM