locked
Where should I store user written methods in LightSwitch RRS feed

  • Question

  • Hi,

    I am writing my own user methods for Tables (Classes) in Lightswitch (HTML Client) and I'm not sure where to store the code.

    Here's how it works at the moment:

    Each table (say) 'Customer' has a generated 'Customer.Isml' file in the 'Data Sources' folder containing the Table Definition.

    When I hit the button to 'Write Code' for the 'Customer_Created' method, it creates a C# Class file called 'Customer.Isml.cs' which is visually attached to the 'Customer.Isml' file above.

    This 'Customer.Isml.cs' file has a class defined as follows: 'public partial class Customer'

    This partial Class works perfectly for storing my own methods within the Customer Class.

    Here's my questions:

    1. Is this the right place to be storing these methods and if not where should I do it?

    2. If this is ok, should I be prefixing the name of my methods to ensure no mix-up between mine and system generated stuff?

    I suppose I'm wondering what the best practice is for this type of thing in LightSwitch?

    Thank you for reading this and I hope it makes sense.

     


    David Corbett

    Wednesday, November 20, 2013 10:28 PM

Answers

  • The "Customer.lsml.cs" file is intended for your user code and LightSwitch will not generate anything into that file without an explicit gesture. There will be no mix-up between your code and generated code.

    Justin Anderson, LightSwitch Development Team

    • Marked as answer by David Corbett Thursday, November 21, 2013 8:40 AM
    Thursday, November 21, 2013 5:35 AM
    Moderator

All replies

  • The "Customer.lsml.cs" file is intended for your user code and LightSwitch will not generate anything into that file without an explicit gesture. There will be no mix-up between your code and generated code.

    Justin Anderson, LightSwitch Development Team

    • Marked as answer by David Corbett Thursday, November 21, 2013 8:40 AM
    Thursday, November 21, 2013 5:35 AM
    Moderator
  • Justin, thank you for clarification.

    How could I invoke such methods from javascript in the Html Client case?

    (I suppose these custom methods written in partial classes, like Customer.lsml.cs, should be exposed to the client and be invoked by means of javascript)

     

    Thursday, December 19, 2013 7:36 AM
  • They are not exposed to the client in HTML client projects in any way. These are sever-side only.

    Justin Anderson, LightSwitch Development Team

    Thursday, December 19, 2013 9:27 AM
    Moderator
  • Ok, thank you

    So the only way to invoke server-side method from html client is to use WEB API

    Right?

    Thursday, December 19, 2013 10:43 AM