locked
Lightswitch Design Question on mixed use business logic RRS feed

  • Question

  • I've looked through many sample apps and am unable to locate this scenario. It probably exists, I just cannot find it. The implementation is a 3-tier, IIS implementation.

    The business logic will execute against a product entity. The product entity has about 100,000 records. The logic will be executed either from the product screen (1 record at a time) or from 4 other non-product screens. On the non-product screens, the logic could run against 2,000 products in a batch.

    Short version of the business logic: For a given product id, execute a LINQ query. The result set will contains 100's of records that contain pieces of information which "describe" the product. The result set is used to do a type of "mail merge" that creates a long name and description for the product. When complete the long name and description are saved to the original product record.

    What I am looking for is a sample app that does something like this:

    1) Button on a product screen that executes code from Common | UserCode. The button click would pass a single entity. In this case, I believe the code could be execute on the client but it may be significantly faster to run it on the middle tier.

    2) Button on a non-product screen that executes the same code. The button click would pass multiple entities. In this case, I would hope to have the code execute on the middle tier.

    Questions:

    1) Is running a process like this on the middle tier acceptable or does it have to run on the client?

    2) Would anyone have a sample of something like this?


    Thank you, Bill

    Wednesday, August 29, 2012 11:49 AM

Answers

  • If I were to do this, below are the steps:

    1. Create a table/entity with fields necessary to process the batch.

    2. Write codes in the Entity_Created method.  Use the data in the fields as parameter.

    3. To execute the batch processing just add a record, that's it.

    If I am not mistaken the Entity_Created method is executed at the server level.


    "HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD"

    HAROLD GLENN MINERVA
    http://hgminerva.wordpress.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. This will help other users to find their answer quickly.

    • Marked as answer by jessiedog Thursday, August 30, 2012 3:43 PM
    Wednesday, August 29, 2012 12:44 PM

All replies

  • If I were to do this, below are the steps:

    1. Create a table/entity with fields necessary to process the batch.

    2. Write codes in the Entity_Created method.  Use the data in the fields as parameter.

    3. To execute the batch processing just add a record, that's it.

    If I am not mistaken the Entity_Created method is executed at the server level.


    "HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD"

    HAROLD GLENN MINERVA
    http://hgminerva.wordpress.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. This will help other users to find their answer quickly.

    • Marked as answer by jessiedog Thursday, August 30, 2012 3:43 PM
    Wednesday, August 29, 2012 12:44 PM
  • Bill:

    Another alternative is to do this:

    1) Write a stored procedure to do your data manipulation.

    2) Use the "Command Table Pattern" to execute the stored procedure.  It sounds like you might be able to pass the Id(s) of the entities as a parameter to the stored procedure.

    This is similar to what Harold is suggesting, as far as the command table, but in some cases I have found that writing a stored procedure is easier and possibly faster.

    If you want more info on this approach, just let me know.

    Mark

    Wednesday, August 29, 2012 9:52 PM
  • Mark,

    Thank you for the post. I am going to start with the logic running inside Lightswitch; if the performance on batches is poor, I will move to sprocs.

    Thank you!

    Sincerely,

    Bill


    Thank you, Bill

    Thursday, August 30, 2012 3:45 PM