none
Create Dynamic Query in EF (VB.Net) RRS feed

  • Question

  • Hi

    I explain my problem with an example. (Entity Framework and VB.net 2012)

    I have two DataGridViews in my form. first DGV populated from a table in SQL (datasource) and second DGV datasource is an empty table in SQL (By Entitiy Faramwork). user must selects some records from DGV1 and sends them to DGV2 by clicking on a button.

    and what is the problem?

    when user sends some records from DGV1 to DGV2, transferred records must eliminate from DGV1 without any change on SQL tables. changes finally will be saved by a button clicking.

    How can create this relation between DGV1 and DGV2 datasources with out any change to main data in SQL??

    I can do this easily in MS Access but i cant do this in EF.

    Any help will be greatly appreciated.




    • Edited by R. Salehi Friday, May 24, 2013 2:32 PM
    Friday, May 24, 2013 2:26 PM

All replies

  • Hi R. Salehi,

    Have you tried any code to implement this feature? Are there any problems with your code?

    For Windows Forms application, we can declare an instance of DbContext for each form. context.SaveChanges() method will finally save the changes to database. You can also have a look of this article about how to do data binding in WinForms applications.

    http://msdn.microsoft.com/en-us/data/jj682076

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 27, 2013 7:28 AM
    Moderator
  • Hi R. Salehi,

    Have you tried any code to implement this feature? Are there any problems with your code?

    For Windows Forms application, we can declare an instance of DbContext for each form. context.SaveChanges() method will finally save the changes to database. You can also have a look of this article about how to do data binding in WinForms applications.

    http://msdn.microsoft.com/en-us/data/jj682076

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Hi Chester.
    Thank u for your replay. I haven't any problem with save changes or filling my DGV with EF. 
    actually I want to make a query (it must be refreshable) in EF between first an 2nd table without any effect on database.
    i don't know my description is clear or no?!
    you can do this very easy in MS Access but in EF??
    Saturday, June 1, 2013 4:33 PM
  • Hi R. Salehi;

    Please post the relevant code for transferring records from DVV1 to DVG2 and how you do the updates to the database. Also please post the schema of the two tables in the database as well.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Sunday, June 2, 2013 12:55 PM
  • Hi R. Salehi;

    Please post the relevant code for transferring records from DVV1 to DVG2 and how you do the updates to the database. Also please post the schema of the two tables in the database as well.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Hi

    Thanks for your reply. I have 2 tables in my form (VB.Net). first table filled by some data and 2nd is empty.

    user must can selects some records (one by one) and send them to 2nd table by clicking on arrow button (as shown in picture). up to this stage, i haven't any problem.

    but transferred records must eliminate from 1st table and i cant do that with Entity Framework.
    i can do this job easily in MS Access like bellowed picture. sorry for my bad English.



    • Edited by R. Salehi Sunday, June 2, 2013 4:23 PM
    Sunday, June 2, 2013 4:22 PM
  • Picture of the UI is nice but where is the code to do all this?

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Sunday, June 2, 2013 4:26 PM
  • Picture of the UI is nice but where is the code to do all this?

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    This is MS Access with VB not VB.Net.
    Sunday, June 2, 2013 4:52 PM
  • As far as creating dynamic queries is concerned, I think PredicateBuilder can help you out alot.

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Monday, June 3, 2013 7:27 AM