locked
Lightswitch - Table_All_PreprocessQuery - run twice??? RRS feed

  • Question

  • Hello,

    I have one simple question - why method "void TAB_TEMPs_All_PreprocessQuery" runs twice?

    AND

    2nd question - how to get something like this "TAB_TEMPs.Count" from code on server (Solution->LS_Project->Server->UserCode->MyClassNeedCount.cs)?

     

    Thanks

    Friday, May 20, 2011 8:36 AM

Answers

  • Hi Matt, thanks for your reply.

    1. I have some code in TAB_TEMP_ALL_PreprocessQuery (get some data from active directory and store them)

    When I focus tab with table on datagrid (TAB_TEMP), TAB_TEMP_ALL_PreprocessQuery will run twice.

    2. I have problem when I use "i = TAB_TEMPs.GetQuery().Execute().Count();" inside All_PreprocessQuery or Executing,

    I have this exception:

    "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"

    probably in GetQuery it will call All_Preprocess (recursive???)

    So I need part of code (on server!) where I can run my code for get active directory info, compare it with existing data (if any exists) and store it.


    Yes -- trying to call GetQuery for the same query inside of its PreProcess method will create an infinite loop.

    The best way to "Fake" an operation on the server is to have a special message/task entity, and to call "Save" from the client in a separate data workspace.  The server can then do processing of the entity, including filling out result or state fields on it, and return those values to the client.  Many threads in the forums describe how to do this.

     

    Monday, May 23, 2011 2:52 PM
  • Good Morning Matt,

    RE:  The best way to "Fake" an operation on the server is to have a special message/task entity, and to call "Save" from the client in a separate data workspace. The server can then do processing of the entity, including filling out result or state fields on it, and return those values to the client. Many threads in the forums describe how to do this.

    Won't all changes in the 2nd DWS cause data conflicts with the initial DWS query in the client?


    Only changes to the same entities will cause conflicts. 

    The message entity should only be used for message passing / calling "operations".  Therefore, changes to it that happen in a separate client dataworkspace should not conflict either with the pending changes in that screen, nor should it cause concurrency problems when saving the "real" entities.

    Monday, May 23, 2011 6:58 PM

All replies

  • anytime client or server runs a query on TAB_TEMPS, the All_PreProcessQuery method will be run.

    what are you doing when you observe that it is run twice?

     

    for getting the count, try:

    int

     

    i = TAB_TEMPs.GetQuery().Execute().Count();

     

    Friday, May 20, 2011 9:06 PM
  • Hi Matt, thanks for your reply.

    1. I have some code in TAB_TEMP_ALL_PreprocessQuery (get some data from active directory and store them)

    When I focus tab with table on datagrid (TAB_TEMP), TAB_TEMP_ALL_PreprocessQuery will run twice.

    2. I have problem when I use "i = TAB_TEMPs.GetQuery().Execute().Count();" inside All_PreprocessQuery or Executing,

    I have this exception:

    "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"

    probably in GetQuery it will call All_Preprocess (recursive???)

    So I need part of code (on server!) where I can run my code for get active directory info, compare it with existing data (if any exists) and store it.

    Monday, May 23, 2011 1:22 PM
  • Hi Matt, thanks for your reply.

    1. I have some code in TAB_TEMP_ALL_PreprocessQuery (get some data from active directory and store them)

    When I focus tab with table on datagrid (TAB_TEMP), TAB_TEMP_ALL_PreprocessQuery will run twice.

    2. I have problem when I use "i = TAB_TEMPs.GetQuery().Execute().Count();" inside All_PreprocessQuery or Executing,

    I have this exception:

    "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"

    probably in GetQuery it will call All_Preprocess (recursive???)

    So I need part of code (on server!) where I can run my code for get active directory info, compare it with existing data (if any exists) and store it.


    Yes -- trying to call GetQuery for the same query inside of its PreProcess method will create an infinite loop.

    The best way to "Fake" an operation on the server is to have a special message/task entity, and to call "Save" from the client in a separate data workspace.  The server can then do processing of the entity, including filling out result or state fields on it, and return those values to the client.  Many threads in the forums describe how to do this.

     

    Monday, May 23, 2011 2:52 PM
  • Good Morning Matt,

    RE:  The best way to "Fake" an operation on the server is to have a special message/task entity, and to call "Save" from the client in a separate data workspace. The server can then do processing of the entity, including filling out result or state fields on it, and return those values to the client. Many threads in the forums describe how to do this.

    Won't all changes in the 2nd DWS cause data conflicts with the initial DWS query in the client?

    Monday, May 23, 2011 5:20 PM
  • Good Morning Matt,

    RE:  The best way to "Fake" an operation on the server is to have a special message/task entity, and to call "Save" from the client in a separate data workspace. The server can then do processing of the entity, including filling out result or state fields on it, and return those values to the client. Many threads in the forums describe how to do this.

    Won't all changes in the 2nd DWS cause data conflicts with the initial DWS query in the client?


    Only changes to the same entities will cause conflicts. 

    The message entity should only be used for message passing / calling "operations".  Therefore, changes to it that happen in a separate client dataworkspace should not conflict either with the pending changes in that screen, nor should it cause concurrency problems when saving the "real" entities.

    Monday, May 23, 2011 6:58 PM