locked
Client side, server side coding... RRS feed

  • Question

  • The following is actually a two fold question:

    When you write SL Business apps, it's very clear what code you write as a server side for WCF or RIA Services and what codes are written as client side Silverlight code to develop a 3-tier app.

    As I'm spending time every day going through the tutorials and learning the basics and how to do preliminary stuff, I can't help it to think about how do we write server side code?And is the code that we write in LS, is it only client side code?

    In SL, I may have a service that performs a batch task (i.e. end of month ledger posting) that the client initiates and it is performed on the server side. For tasks that are batch oriented and clearly needs to be done on server, how do we go about building these in LS.

    Thanks!
    ..Ben


    WPF/Silverlight Insider
    Thursday, September 16, 2010 10:44 PM

Answers

  • Hi Ben,

    You can write server side code in LS. There are three places the user can write code: Client project, Server project and Common project. You can think as the screens related code goes into Client project, the EntitySet (similar to tables) related code like additional operations you want to do before inserting/updating/deleting any records in the database table goes in the server project. The common validation you want to share between client and server project goes into the Common project. You can see all these projects when you switch to the File view (To switch to file view: Click the toggle button in the solution explorer next to the refresh button).

    For example:

    I created table (Table1Items) and added a field (Property1 of type String). Now I want some server side logic that before inserting any new record in the Table, do some additional operation. I will open the Table1Items in the designer and open the drop down options for writing code on the server project (click the arrow for Write Code on the top right side of the designer). If you hover over the links you will see the tool tip information about where the code will be running. For example Table1Items_Inserting link/method will put the code on the server project. If you click on that link, it will open the code behind file and create a new method stub Table1Items_Inserting. This file is created on the server project. You can verify this by switching to File View -> Server -> UserCode. A new file will be created (ApplicationDataService.vb).

     

    Similarly, you can also write code on the client project by Opening any screen you created in the designer and navigating to the write code drop down.

     

    Hope that answers some of your questions.

     

    Thanks,

    Sushil Magdum

     

    • Proposed as answer by Steve HoagModerator Wednesday, September 22, 2010 2:27 AM
    • Marked as answer by Ben Hayat Wednesday, September 22, 2010 3:07 AM
    Wednesday, September 22, 2010 1:27 AM

All replies

  • I'm struggling with that one myself. For a Tax Accountant's application, periodic update of tax document due dates should happen. In the Access version of this app, it happened via an implicit call to SQL during the Splash Screen loadup. Not sure whether to look at a trigger firing on an insert to a dummy table and calling a stored procedure that runs the job, or some other way to trick an invoke through the RIA wire. Sure wish Danesh had spent some  (or more) time in the business world :). These are the kinds of things that we're missing out of the box.
    If you believe that I've answered your question, please remember to mark it as answered.

    MicroApplications, Inc. -- Information Systems Integration and Custom Software Development
    Friday, September 17, 2010 2:29 AM
  • I'd like to see a clear guidelines on these types of processes and how they think is the best approach!

    ..Ben


    WPF/Silverlight Insider
    Friday, September 17, 2010 3:30 AM
  • Any comments from the team on this?

    WPF/Silverlight Insider
    Friday, September 17, 2010 10:53 PM
  • I've written a couple batch processes that ran on the LS client.  They were understandably slow.   We know that performance will be improved.  However, we also know that we will NEVER run batch updates on the client.

    We do need to know how to create a classes and call methods that run on the server.  There should be a way to send back a message to a client screen when the batch has finished.

    Does Beta 1 have the ability to instantiate classes that run on the server with method calls initiated from client screens?

    If not, do we need to post a request for this in Beta 2?

    Saturday, September 18, 2010 5:16 PM
  • Since I'm in early stage of exploration and trying to get a good understanding of overall LS, I like to find out:

    a) Do we write WCF services in a separate project and call them from LS client for server side processing?

    b) Do we write Server side code in LS?

    c) Are all the codes written in LS, considered to be as "Client" code? If not, how do we differentiate what's "Client" code and what's "Server" code?

    I would like to get some documents/diagram how the 3-tier model is working within LS and where do we, as "Developers" are going to plugin codes that relate to each tier.

    Looking for the team to shed some light on this subject.

    Thanks in advance!
    ..Ben


    WPF/Silverlight Insider
    • Proposed as answer by Sushil Magdum Wednesday, September 22, 2010 12:55 AM
    Saturday, September 18, 2010 7:00 PM
  • Hi Ben,

    You can write server side code in LS. There are three places the user can write code: Client project, Server project and Common project. You can think as the screens related code goes into Client project, the EntitySet (similar to tables) related code like additional operations you want to do before inserting/updating/deleting any records in the database table goes in the server project. The common validation you want to share between client and server project goes into the Common project. You can see all these projects when you switch to the File view (To switch to file view: Click the toggle button in the solution explorer next to the refresh button).

    For example:

    I created table (Table1Items) and added a field (Property1 of type String). Now I want some server side logic that before inserting any new record in the Table, do some additional operation. I will open the Table1Items in the designer and open the drop down options for writing code on the server project (click the arrow for Write Code on the top right side of the designer). If you hover over the links you will see the tool tip information about where the code will be running. For example Table1Items_Inserting link/method will put the code on the server project. If you click on that link, it will open the code behind file and create a new method stub Table1Items_Inserting. This file is created on the server project. You can verify this by switching to File View -> Server -> UserCode. A new file will be created (ApplicationDataService.vb).

     

    Similarly, you can also write code on the client project by Opening any screen you created in the designer and navigating to the write code drop down.

     

    Hope that answers some of your questions.

     

    Thanks,

    Sushil Magdum

     

    • Proposed as answer by Steve HoagModerator Wednesday, September 22, 2010 2:27 AM
    • Marked as answer by Ben Hayat Wednesday, September 22, 2010 3:07 AM
    Wednesday, September 22, 2010 1:27 AM
  • Hey Sushil can't thank you enough for giving me the exact answer. Thanks!

    WPF/Silverlight Insider
    Wednesday, September 22, 2010 3:09 AM
  • @Steve;

    Steve, the above comments that Sushil made could be very helpful and I hope you can expand on them in your documentation.

    Thanks!
    ..Ben


    WPF/Silverlight Insider
    Wednesday, September 22, 2010 2:44 PM