locked
Can´t connect to RIA Service in Lightswitch application RRS feed

  • Question

  • Since few days I am trying to do the RIA service for my Lightswitch application, I have tried many options who I found on net. not going to mention all of them, the list is long, for example from here I started http://lightswitchhelpwebsite.com/, and every time whene I try to add this service to LS AP see in a reference this yellow triangle and can not connect to the data ,  I ran out of ideas. If anyone have any idea or know about some manual how to do in Visual Studio 2013. I appreciate much


    Tomasz

    Thursday, October 16, 2014 2:13 PM

Answers

  • The problem solved by changing Target Framework in WCF_RIA_Project from 4.5.1 to 4.5 all problems disappeared

    And i if you want to show data from two or more tables so the code is:

    [Query(IsDefault = true)]
            public IQueryable<littlelist> getlist()
            {
               
                var colB = from Invoices in context.Invoices
                select new littlelist
                               {
                                   ID = Invoices.Id,                               
                                   Organization = Invoices.Client.Organization,
                                   Street = Invoices.Client.Street,
                                   NrInvoice = Invoices.NrInvoice,
                                   Total = Invoices.Total,
                                   Description = Invoices.Description.Descripcion
                                   
                               };
                return colB;
            }

    but this depends on relationship

    in this case is =>many invoices to one client and => many description to one invoice

    Thanks all form help.


    Tomasz


    Saturday, October 18, 2014 10:19 AM

All replies

  • Can you provide the exact link you used on LightSwitchHelpWebsite.com? I do not think there is an article to connect to an "external" WCF RIA Service that is up to date for Visual Studio 2013 (they made changes).

    All the current articles are for making a WCF RIA Service connected to the "internal" data source.


    Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book

    http://LightSwitchHelpWebsite.com

    Thursday, October 16, 2014 3:49 PM
  • My intention is to get data from two tables and join in a one table, then usingOfficeIntegrationPach to print/save  Word document and print/save PDF according Fun With OfficeIntegrationPack , I studied following articles Combinig Tow Tables and Creating a WCF RIA Service for Visual Studio LightSwitch 2013.

    Last I create WCF RIA independent, and join to my project with "Add-ExistingProject" and now this yellow triangel not apeare, but data is not charged.


    Tomasz

    Thursday, October 16, 2014 6:09 PM
  • Creating a WCF RIA Service for Visual Studio LightSwitch 2013 is the only one that is up to date, but it does not describe how to connect to an external data source, so I am not surprised if it did not work for you :(

    Unfortunately I do not know of a up to article that describes the process. It may exist, I am just not aware of it.


    Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book

    http://LightSwitchHelpWebsite.com

    Thursday, October 16, 2014 7:25 PM
  • Creating a WCF RIA Service for Visual Studio LightSwitch 2013 works fine with an external data source.

    All you need to do is:

    1) add a link to YourDataSourceObjectContext.cs instead of ApplicationDataObjectContext.cs;

    2) modify the connection string code a little:

    public ApplicationData Context
    
            {
    
                get
    
                {
    
                    if (this.m_context == null)
    
                    {
    
                        string connString =
    
                            System.Web.Configuration.WebConfigurationManager
    
                            .ConnectionStrings["YourDataSourceName"].ConnectionString;
    
                        EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
    
                        builder.Metadata =
    
                            "res://*/YourDataSource.csdl|res://*/YourDataSource.ssdl|res://*/YourDataSource.msl";
    
                        builder.Provider =
    
                            "System.Data.SqlClient";
    
                        builder.ProviderConnectionString = connString;
    
                        this.m_context = new YourDataSourceName(builder.ConnectionString);
    
                    }
    
                    return this.m_context;
    
                }
    
            }
    
    
    Everything else in the tutorial should work the same.

    Thursday, October 16, 2014 8:08 PM
  • OK today again i try to do this , without results.

    I have two tables "Clients" and "Invoice" following this article Combined Two Tables step by stepwith some change for VS 2013.

    Thi is my code

    using System.Linq;
    using System.Data.EntityClient;
    using System.ComponentModel.DataAnnotations;
    using System.ServiceModel.DomainServices.Server;
    using LightSwitchApplication.Implementation;
    
    namespace RIA_Project
    {
        public class littlelist
        {
            [Key]
            public int ID { get; set; }
            public string Organization { get; set; }
            public string NrInvoice { get; set; }
        }
    
        public class RIA_Service : DomainService
        {
            private ApplicationData m_context;
    
            public ApplicationData context
            {
                get
                {
                    if (this.m_context == null)
                    {
                        string connString =
                            System.Web.Configuration.WebConfigurationManager
                            .ConnectionStrings["_IntrinsicData"].ConnectionString;
                        EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
                        builder.Metadata =
                            "res://*/ApplicationData.csdl|res://*/ApplicationData.ssdl|res://*/ApplicationData.msl";
                        builder.Provider =
                            "System.Data.SqlClient";
                        builder.ProviderConnectionString = connString;
                        this.m_context = new ApplicationData(builder.ConnectionString);
                    }
                    return this.m_context;
                }
                
            }
            [Query(IsDefault = true)]
            public IQueryable<littlelist> getlist()
            {
                var colA = from Clients in context.Clients
                           select new littlelist
                               {
                                   ID = Clients.Id * (-1),
                                   Organization = Clients.Organization,
                               };
                var colB = from Invoices in context.Invoices
                           select new littlelist
                               {
                                   ID = Invoices.Id,
                                   NrInvoice = Invoices.NrInvoice,
                               };
                return colA.Union(colB);
            }
            protected override int Count<T>(IQueryable<T> query)
            {
                return query.Count();
            }
        }
        
    }
    

    effect is the same 

    I try creat new clean project and try again 


    Tomasz

    Friday, October 17, 2014 4:09 PM
  • Hi Michael

    I started step by step to create an application, I started from here An End-To-End Visual Studio LightSwitch HTML5 Application 

    the first thing that I discovered, in your example the UserName not apeare when I create new order, I checked if I'm not missing letters, and if everything is written correct. Nothing, without result, but if i write in textbox any name, after save in list apeare "TestUser".

    I go ahead, and I will you comment how it goes :)


    Tomasz


    Saturday, October 18, 2014 12:34 AM
  • Hi Michael

    I started step by step to create an application, I started from here An End-To-End Visual Studio LightSwitch HTML5 Application 

    the first thing that I discovered, in your example the UserName not apeare when I create new order, I checked if I'm not missing letters, and if everything is written correct. Nothing, without result, but if i write in textbox any name, after save in list apeare "TestUser".

    I go ahead, and I will you comment how it goes :)


    Tomasz



    I am confused, why are you doing An End-To-End Visual Studio LightSwitch HTML5  Application?  Why are you not doing Creating a WCF RIA Service for Visual Studio LightSwitch 2013?

    Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book

    http://LightSwitchHelpWebsite.com

    Saturday, October 18, 2014 1:30 AM
  • to deal with the same data as in your article

    but this morning I fell Surprised, I opened the program to continue, without changing anything in the code, i start my proyect, and it works, the user name appears in the text field. Sometimes I think, if this can be problem of my Visual Studio.


    Tomasz


    Saturday, October 18, 2014 8:44 AM
  • The problem solved by changing Target Framework in WCF_RIA_Project from 4.5.1 to 4.5 all problems disappeared

    And i if you want to show data from two or more tables so the code is:

    [Query(IsDefault = true)]
            public IQueryable<littlelist> getlist()
            {
               
                var colB = from Invoices in context.Invoices
                select new littlelist
                               {
                                   ID = Invoices.Id,                               
                                   Organization = Invoices.Client.Organization,
                                   Street = Invoices.Client.Street,
                                   NrInvoice = Invoices.NrInvoice,
                                   Total = Invoices.Total,
                                   Description = Invoices.Description.Descripcion
                                   
                               };
                return colB;
            }

    but this depends on relationship

    in this case is =>many invoices to one client and => many description to one invoice

    Thanks all form help.


    Tomasz


    Saturday, October 18, 2014 10:19 AM