locked
Using WCF RIA service with parameters in Lightswitch HTML RRS feed

  • Question

  • Hi guys!

    It could be really easy for you to answer, but I couldnt find any info.

    I have a RIA service and default method

            [Query(IsDefault = true)]
            public IQueryable<CustomerRecord> GetSampleCustomerData()
            {
                return _sampleCustomerRecordList.AsQueryable();
            }
    
            public IQueryable<CustomerRecord> GetSampleCustomerParam(int? AllRecordsbyId)
            {
                return _sampleCustomerRecordList.AsQueryable();
            }

    I am trying to add another iqueryable method. I have updated code, rebuiled the project, Update the data source. I dont understand how I can use it now in my LightSwitch HTML. When I add data source I can see only one Entity which is "Customer Record". How can I show results from that second method? Where should it be display to pick?

    Thanks

    Nick

    Thursday, October 3, 2013 3:52 AM

Answers

  • Hi Nick,

    You have to implement the insert method yourself, refer to the MSDN walkthrough:

    Creating a Data Source Extension

    public void InsertProduct(Product p)
            {
                try
                {
                    p.ProductID = Guid.NewGuid();
                    XElement productElem = GetProductElem(p);
                    _db.Element("Products").Add(productElem);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error inserting Product " + p.ProductName, ex);
                }
            }
    

    Cheers

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by nicksav Thursday, October 3, 2013 1:27 PM
    Thursday, October 3, 2013 8:14 AM

All replies

  • I think I get it worked. For some reason Update Data Source didn't make any differences, till I deleted generated .cs files related to domain service.

    Have another question. I see that there 3 different methods: Query fro data. Update and Delete. Where is Insert?

    And how to specify Insert? When I am creating a screen and adding new Command Bar button with AddAndEdit command, this button is hidden from the screen? 

    Any ideas?


    • Edited by nicksav Thursday, October 3, 2013 6:39 AM
    Thursday, October 3, 2013 6:28 AM
  • Hi Nick,

    You have to implement the insert method yourself, refer to the MSDN walkthrough:

    Creating a Data Source Extension

    public void InsertProduct(Product p)
            {
                try
                {
                    p.ProductID = Guid.NewGuid();
                    XElement productElem = GetProductElem(p);
                    _db.Element("Products").Add(productElem);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error inserting Product " + p.ProductName, ex);
                }
            }
    

    Cheers

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by nicksav Thursday, October 3, 2013 1:27 PM
    Thursday, October 3, 2013 8:14 AM