Putting Studio for Entity Framework to Use

Putting Studio for Entity Framework to Use

Putting Studio for Entity Framework to use A Brief Guide Dom Sinclair Table of Contents Foreword ....................................................................................................................................................................... 4 Introduction ...................................................................................................................................................................... 5 Getting Started: The Data Model ................................................................................................................................. 7 Getting Started: Referencing the data model ............................................................................................................ 10 Getting Started: The C1DataSource Component ....................................................................................................... 11 Getting Started: Binding controls to the C1DataSource ............................................................................................ 17 Querying, Editing and Adding data with the C1DataSource ........................................................................................... 25 Querying Data without writing code .......................................................................................................................... 25 Saving Changes made to the data ............................................................................................................................... 28 Using the S.E.F. for a real world example ....................................................................................................................... 31 Database first or Code first? ....................................................................................................................................... 32 The Data Model ........................................................................................................................................................... 32 The Entity Model Connection String ........................................................................................................................... 36 Entity Framework Connection Strings .................................................................................................................... 36 Creating a dynamic connection string for the SEF .................................................................................................. 37 Extending the Data Model .......................................................................................................................................... 41 Building the first User Interface .................................................................................................................................. 45 Validating, Saving and the whole business of Transactions ....................................................................................... 53 Basic Validation ....................................................................................................................................................... 53 Saving the data ........................................................................................................................................................ 56 Figure 1: The Add New Item Dialog ................................................................................................................................. 7 Figure 2: Add Data Model Wizard; Stage 1 ...................................................................................................................... 8 Figure 3: Add Data Model Wizard; Stage 2 ...................................................................................................................... 8 Figure 4: Add Data Model Wizard; Stage 3 ...................................................................................................................... 9 Figure 5: The completed Entity Data Model .................................................................................................................... 9 Figure 6: Solution Explorer showing the solution after the data model project has been added ................................. 10 Figure 7: Solution Explorer showing the reference to the data model added to the SefTrial project .......................... 11 Figure 8: C1 Studio for Entity Framework as it appears in the Visual Studio Toolbox ................................................... 11 Figure 9: Setting the Specific Version Property ............................................................................................................. 12 Figure 10: The properties window for the C1DataSource .............................................................................................. 13 Figure 11: The EntityViewSouce Collections Editor of the C1DataSource ...................................................................... 13 2 Figure 12: Changing the DataMember and DataSource properties of the C1FlexGrid .................................................. 14 Figure 13: The drop down you'll see in the DataMember property of the grid showing The Products table accessible from Categories............................................................................................................................................................... 14 Figure 14: The SefTrial showing the Category and Products tables............................................................................... 15 Figure 15: The Entity Framework attempting to resolve the relationship between Categories and Products. ............ 16 Figure 16: The special ControlHandler property added by the C1DataSource ............................................................... 16 Figure 17: Resolving the relationship between Categories and Products with the C1DataSource. .............................. 17 Figure 18: The DataBindings section in a standard Text Box's Properties dialog. .......................................................... 18 Figure 19: The Formatting and Advanced Binding Dialog. ............................................................................................. 19 Figure 20: Setting the Data Source Update Mode. ........................................................................................................ 20 Figure 21: Setting the Text property of a standard TextBox to a Data Source in the properties window. .................... 21 Figure 22: The properties window for a C1 TextBox showing their additional properties that make Data Binding a little easier. ..................................................................................................................................................................... 21 Figure 23: The SefTrial showing the addition of text boxes to display Category data................................................... 22 Figure 24: The Edit Items Dialog of the C1 InputPanel .................................................................................................. 23 Figure 25: The project settings showing the application tab ......................................................................................... 23 Figure 26: The C1 Input Panel displaying the Categories table...................................................................................... 24 Figure 27: The FilterDescriptor Properties Collection Editor ......................................................................................... 26 Figure 28: The available options for the Operator property of the Filter Descriptor .................................................... 26 Figure 29: The SortDescriptor Properties Collection Editor ........................................................................................... 27 Figure 30: The database diagram of the database section to be modelled .................................................................. 33 Figure 31: The Entity Data Model as created by Visual Studio. ..................................................................................... 34 Figure 32: The Microsoft Data Connection Dialog configured to only allow SqlClient connections. ............................ 39 Figure 33: The relationship between Sites and Extinguisher Locations. ....................................................................... 41 Figure 34: A typical problem that might occur where the same information appears in the field that the SEF uses to resolve relations between tables. ................................................................................................................................... 42 Figure 35: The FlexGid configured to enter Extinguisher locations. .............................................................................. 46 Figure 36: Fields in the Extinguisher Locations Table. .................................................................................................... 47 3 Foreword In September of 2010 I decided to treat myself to a little light reading for my annual break. The book in question was on the Entity Framework, a subject I’d read a few articles on and one which I felt I ought to learn a little more about. The book was a revelation, convincing me that in the future any new data centric applications that I was going to build or seriously upgrade should make use of it. A couple of months later I suggested to friend that he read the book I was in the process of re-reading for the third time. I’m glad to

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    56 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us