How to achieve parallel execution of two or more Entity Framework queries?

Hi Everyone,
I'm creating some WCF service that use EF to query the database for the data that I need. The problem I have at the moment is that I have 2 or more EF LINQ queries which are declared and then executed to bring back my data... but this is in serial. One EF query is issued, and then the next one after that.
Does anyone know of a simple way to issue the queries in parallel? Or am I looking at async /parallel tasks to get the correct behaviour.
I know the DBContext is not thread safe, so I have no problem in declaring multiple contexts if required.
The code so far is as below:
+using (IMyContext ctx = MyFactory.GetInstance(request.UserId)) {+
Response response = new Response();
response.customer = ctx.GetCustomerByAccount(request.data.Account);
response.custInfo = ctx.GetCustInfoByAccount(request.data.Account);
response.address = ctx.GetDefaultAddressByAccount(request.data.Account);
return response;
+}+
Thanks in advance,
Nick

Hi,
Although I don't understand why you need to serialized two programs
that have no dependency on each other, maybe the following code can help provided the programs are executed using specific tcodes.
  DATA: BEGIN OF USR_TABL OCCURS 10.
          INCLUDE STRUCTURE UINFO.
  DATA: END OF USR_TABL.
CONSTANTS: OPCODE_LIST LIKE TH_OPCODE VALUE 2.
  refresh USR_TABL.
  CALL 'ThUsrInfo' ID 'OPCODE' field OPCODE_LIST
    ID 'TAB' FIELD USR_TABL-SYS.
  sort usr_tabl by mandt bname.
You can check wheter the other program(tcode) is being run from itab USR_TABL, good luck.
Jeffrey Satriadi

Similar Messages

  • How to share the data between two or more frames

    How to share the data between two or more frames based on the database relationship in JDeveloper?

    You can pass data between frames by passing it as parameters.
    That is when you are invoking another frame, pass your data as arguments through the constructor to that frame .
    You can also achieve this through static or public methods, but static variables as we know is not suggested which might occupy more memory space.
    Regards,
    Srinivasan AShwath
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by [email protected]:
    How to share the data between two or more frames based on the database relationship in JDeveloper? <HR></BLOCKQUOTE>
    null

  • Did you know how to link the text in two or more text boxes?

    Did anyone know how to link the text in two or more text boxes in Pages 5.0? Thanks for your answer.
    Qualcuno sa come collegare il testo in due o più caselle di testo nella versione 5.0 di Pages. Grazie per le vostre risposte.

    It's just one of the many, many features that have been eliminated or changed. Leave feedback for the Pages team using the link in the Pages menu and review & rate the new versions in the Mac App Store.
    If you previously had iWork '09, those apps are still in your Applications folder in a folder named iWork '09. You can continue to use them to get things done.

  • How sharing an audio stream in two or more Ip telephones?

    Hi everybody.
    I wonder if you can make a call in which two or more people can listen to the conversation without using the functionality of the conference or the contact center, in other words, two or more IP phones have the functionality to take the call and listen to the conversation.
    analog lines similar to accounts in which a line with several phones and all phones that are connected to it can hear the conversation.
    I hope you understand me
    regards

    Hi Mauro,
    You can use "Shared Lines" with Barge
    Look for "Single Button Barge"  to simplify the user experience.
    http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/admin/8_5_1/ccmfeat/fsbarge.html#wp1034920
    Cheers!
    Rob
    "When it comes to luck you make your own  " 
    - Springsteen

  • How to create ViewModel in an MVVM application using entity framework where database has many-to-many relationship?

    I have started developing a small application in WPF. Since I am completely new to it, to start with I took a microsoft's sample available at
    Microsoft Sample Application and following the pattern of the sampke I have been so far successful  in creating four different views for their corresponding
    master tables. Unfortunately, I have got stuck up as the sample does not contain pattern for creating ViewModel when there is a many-to-many relationship in the database. In my application, I have the following data structure:
    1. Table Advocate(advId, Name)
    2. Table Party (partyId, Name)
    3 Table Case (caseId, CaseNo)
    4. Link Table Petitioner (CaseId, PartyId)
    5. Link Table Respondent (CaseId, PartyId)
    6. Link Table EngagedAdvocate(CaseId, advId)
    7. Link Table EngagedSrAdvocate(CaseId, advId)
    In the scenario above, I am a bit confused about how to go forward creating the required ViewModel which would render me to have multiple instances of Petitioners, Respondents, Advocates and SrAdvocates.
    Please explain details in step by step manner considering that whatever work I have completed so far is a replica of Microsoft's sample referred above. I would also like to mention that I have developed my application
    using VB.net. So please provide solution in vb.net.
    After getting many-to-many relationship introduced into my application, it would achieve one level above the sample application and I would like to share with the community so that it could be helpful to many aspiring developers seeking help with MVVM.

    Hi ArunKhatri,
    I would suggest you referring to Magnus's article, it provides an example of how you could display and let the user edit many-to-many relational data from the Entity Framework in a dynamic and data-bound DataGrid control in WPF:
    http://social.technet.microsoft.com/wiki/contents/articles/20719.wpf-displaying-and-editing-many-to-many-relational-data-in-a-datagrid.aspx
    You can learn how to design the ViewModel and the relationship between the entities.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to achieve parallel processing in a single request?

    Hi all,
    I have a method in a Session EJB that will perform some business logic before it returns an answer to the client. The logic it will perform is to collect data from the applications database and two external systems, before sending all data to a third external system to get a response and send it back to the client. Each external system is quite slow so I would like to do all the collecting of data concurrent, parallel processing. How should I handle this? I'm not allowed to create my own threads in EJB's. Can I use MDB in some way? To the calling client this should be a synchronous call...
    Greatfull for any suggestions
    Cheers
    Anders =)

    Usually, the request is received by a component located in the web container, such as by an HTTP request (including Web Services). This component is able to start threads to allow parallel processing. Now, if for some reason the request arrives directly at EJB level and that you cannot move its receiver to web component, I think JMS is not a viable solution because you will switch to asynchronous processing and you have no way to make your EJB wait for the responses while preserving the client request (waiting implies programmatic life cycle management, which is forbidden in EJB container). Maybe a resource adapter (JCA) can bring a solution. A resource adapter acts as a datasource (a datasource is a specialization of a resource adapter) and thus it is a logical way to implement an adapter to an external, eventually non-J2EE, resource, as the name implies :) But I don't have enough knowledge in JCA to be sure of this.
    Hope it helps.
    Bruno Collet
    http://www.practicalsoftwarearchitect.com

  • How to restrict simultaneous execution of two programs?

    Hi Experts,
    Need inputs for the situation described below:
    We have two programs prog A and prog B. These are independent executable programs and have no dependency on each other. I want to restrict execution of prog B if prog A is running in any session by any user. Is there any system/basis table which stores runtime status of all the programs? There should be some table where all the currently executing programs get stored and once program is completed, entry is cleared from the table.
    One way can be:
    When prog A has started execution, add an entry in any Z table and at the time of finishing delete the particular entry. In prog B check that the table has any entry for prog A. If yes that means prog A is still running.
    Issue with this approach is, if program A has some error or cancelled while execution, it will not delete its own entry and hence even if prog A is finished, prog B will find entry in Ztable. 
    Any other way to achieve this functionality?
    This is very urgent.Please help!
    TIA
    Abhishek

    Hi,
    Although I don't understand why you need to serialized two programs
    that have no dependency on each other, maybe the following code can help provided the programs are executed using specific tcodes.
      DATA: BEGIN OF USR_TABL OCCURS 10.
              INCLUDE STRUCTURE UINFO.
      DATA: END OF USR_TABL.
    CONSTANTS: OPCODE_LIST LIKE TH_OPCODE VALUE 2.
      refresh USR_TABL.
      CALL 'ThUsrInfo' ID 'OPCODE' field OPCODE_LIST
        ID 'TAB' FIELD USR_TABL-SYS.
      sort usr_tabl by mandt bname.
    You can check wheter the other program(tcode) is being run from itab USR_TABL, good luck.
    Jeffrey Satriadi

  • How to see parallel execution servers

    Hi
    From a session I am running a query in parallel. Having the session's ID and serial number I want to identify the query coordinator process and the slave processes which run in parallel.
    Please, tell me from which views and how can I query this information?
    So far, I tried this:
    SELECT * FROM gv$px_session WHERE sid = <MY_PARALLEL_SESS_SID>;However it didn't returned any rows. I know the session's query is running in parallel because of the execution plan.
    My database version is 11.2.0.2 and my OS is Oracle Solaris 10 X86
    Thank you!

    Thank you for you reply!
    However, the reason I didn't see any rows was that another session had occupied all the parallel processes without releasing them.
    Once they were released, my session took them and I could see them in the views.
    Nevertheless, thank you for the link, I will definitely read it.

  • How to avoid parallel execution

    Hello!
    In my database is present undesirable parallelization of the query.
    All involved tables has degree=1,
    if I right understood there is no method to avoid this except reducing of degree of indexes ?
    I'm usung 11.2.0.3
    Thanks and regards,
    Pavel

    Well, you can use the NOPARALLEL hint if you don't want parallelism to be there.
    Aman....

  • How to use one stream by two or more threads?

    Hey guys,
    i have got a little problem and do not know how to solve it. i hope you guys can are able to help me.
    i have opened a bluetooth socket connection. now i want to use these streams by three or more threads. one thread should only read from an input stream. the other threads are supposed to write on the ouput stream.
    (I think) I am only able to open one stream in each direction.
    How do I realize the use of the output stream by two indepent threads?
    thanks for your help!

    thank you for the hint!
    i will search it or do you know a good tutorial?

  • PLEASE HELP how do you make gravity around two or more points that effects a ball or so on

    hi
    i have been trying for hours to make a ball that if effected by two points of gravity a bit like http://activeden.net/item/gravity-simulator/15437 this but i can not code it and i can not find any tutorials that show you how to do it.
    hope some one can help
    thanks

    So here's some more info, Not only have i never used a mac before, I don't really know how to use one, and my girlfriend is at school pretty far away right now, shes not good with computers either. So i don't wanna have to resort to asking her to install jmf on her macbook. If i do have to do that i guess i could get her friend to help her out.
    But i'd still rather get this problem fixed. How do i incorperate jmf with my program, so it runs on all computers. I checked the native folder in SipCommunicator 1 release 2 and 3, but its only one dll file called ShellLink.dll
    I checked everywhere in both of the downloads and i couldn't find any other dlls.
    I must be downloading the wrong thing....
    I downloaded
    SIP Communicator 1.0-alpha2 release: Generic installer for all OSs
    and also
    SIP Communicator 1.0-alpha3 nightly builds: Generic installer for all OSs, Java installation required
    The reason i got the generic installer is because I have a vista, and i want to run this on a mac. I don't have or know any one living near me with a mac, so i need to be able to build it on my comp.

  • How to get different field in two are more different table using open sql

    Dear all,
              This SenthilMani am very new into sap abap am having doubt in reports how get the different fields from different tables like mara,marc,mard using open sql and native sql program give me some tips to get the data .
    with regards,
    senthil

    HI ,
      1) If u want to select data from more the two table then u can use FOR ALL ENTRIES.
             EX ..Open sql
                       select matnr from mara into table t_mara.
                      select matnr werks from marc into table t_marc for all entries in t_mara where matnr = t_mara-matnr.
      2) U can join more than one table.
               ex:
                   select mara~matnr
                              marc~werks
                    from mara join marc into table t_maramarc
                     on maramatnr = marcmatnr
    3) Using  native sql  ...only u can use JOIN statement

  • PRE9: How to split one clip into two (or more) clips?

    I can't believe this is so hard to do... But HOW?

    You don't necessarily need to separate the file into individual clips.  When you do a cut on the timeline, this is a virtual cut, leaving the original file untouched but determining what will appear in the output.  You can split the clip into multiple pieces, delete the bits you don't want, add transitions, insert new bits, whatever you want, all without affecting the original file in any way.  Once you're happy, you output a new file using the Share options, and you get a new video file, with your original files still untouched.
    If you want to split your file into multiple individual files, you can use the sliders on the time scale, and export (Share) using the Share Work Area Only checkbox.  If you're doing this for purposes of reassembly, it would be better to save the individual clips in as lossless a format as possible, the default AVI format taking considerably more space but not losing quality.  Hint: the sliders can be positioned to the time marker using Alt-[ and Alt-].  Once you've done this, note that your original file will still be there, untouched.
    There is also VideoRedo Plus, a cheap program which gives frame-accurate selection and allows rapid subdivision of a piece of footage.  It doesn't re-render as PE9 would (this is where loss of image quality creeps in using compressed formats such as MPEG), copying the original frames.  You can then reassemble the bits using your video editor.

  • How to split a graph in two or more pages

    Hi, I would like to know if it's possibile make a graph to be visualized on more than one page (horizontally)
    In my case I have a query that extracts a lot of results (so I have a lot of points on the X axis),
    and I'd like to make it easier to read it, making the graph wider.
    I tried to insert the graph in a record group setting max record count, but it seems that Reports goes in an
    infinite loop during the layout generation...
    Thanks in advance.
    A.R.

    java.io.FileInputStream
    java.io.FileOutputStream
    $ split --help
    Usage: split [OPTION] [INPUT [PREFIX]]
    Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
    PREFIX is `x'.  With no INPUT, or when INPUT is -, read standard input.
    Mandatory arguments to long options are mandatory for short options too.
      -a, --suffix-length=N   use suffixes of length N (default 2)
      -b, --bytes=SIZE        put SIZE bytes per output file
      -C, --line-bytes=SIZE   put at most SIZE bytes of lines per output file
      -d, --numeric-suffixes  use numeric suffixes instead of alphabetic
      -l, --lines=NUMBER      put NUMBER lines per output file
          --verbose           print a diagnostic to standard error just
                                before each output file is opened
          --help     display this help and exit
          --version  output version information and exit
    SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.

  • Parallel execution of multiple scripts

    Hi All,
    I understand that by using parallel hint we can achieve parallel execution of the queries(insert/update/delete).
    For my today's question I would like know if Parallelism can be achieved for the following scenario.
    I have a script with an insert-select statement and multiple merge statements and few update statements all on the same table.
    I have to run this script 12 times on the same table, once for each month of the year.
    Currently we run for Jan (where record_date = '201001') commit it, and then run for Feb, and so on.
    Can all the 12 month be run in parallel. One way I can think of is create 12 different scripts and kick them of by opening 12 different SQL Plus sessions (all on the same table).
    Is there a better way of doing this ?
    Note: each month data will not effect the other other month data.
    Regards,
    Aj

    Creating 12 different scripts would be a sub-optimal solution, and a maintenance nightmare. Creating 1 parametrized script and call that 12 times with different parameters would be slightly better.
    Creating 1 stored procedure with parameters, and run that procedure in the scheduler 12 times would still be better, as everything runs at the server side only.
    Your description is deliberately vague, so the possibility of deadlock can not be excluded.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for