130 likes | 144 Views
Explore the functionalities of ADO.NET and Entity Framework in data access for web applications, covering SQL Server, Oracle, MySQL, and ODBC databases. Learn about programmatically accessing data, Entity Framework with LINQ, MVC approach, and ORM concepts for efficient data retrieval.
E N D
Overview of Data Access MIS 324 Professor Sandvig
Overview • ADO.NET overview • Data Access • Displaying data
ADO.NET Overview • “Any web application worth writing involves data access.” Stephen Walther • ADO.NET • ActiveX Data Objects • Microsoft’s data access technologies • Set of classes that provide data access services • Class Library: ADO.NET Overview
ADO.NET Overview • Support for most relational databases • Sql Server • Oracle • MySql • Any ODBC compliant database • Open Database Connectivity standard
.NET Data options • Programmatically • Use connection & command objects • Pass SQL to database • Very flexible approach • Similar to PHP • Entity Framework • VS examines database • Creates classes representing database structure • Query with LINQ (language integrated query) • Intellisense support • Added to .NET 3.5 • Proprietary Microsoft product
Retrieving Data • MIS 324 • Will use programmatic approach • Benefits • Flexible • Uses SQL • Standard OOP programming techniques • MIS 424 • Entity Framework • Fast & convenient
MVC Approach • Separation of duties: • Model • Describes application data • DataRepository class • Sql statements and data access classes • Controller • Handles requests • View • Displays data and forms
Repository • All data access logic • Sql statements • Database classes • Connection • Etc. • Goal: Loose coupling • Different data source affects only repository
ORM – Object Relation Mapper • Maps model to sql parameters • Query results to model
ORM • We use Dapper ORM • Developed by StackOverflow • For its site • “King of ORMs”
Retrieving Data .NET MVC Steps: • Model • Database (Sql Server) • DataRepository • Controller • Views
Example – Repository • See handout: Read Database • Output
Summary • ADO.NET • Classes that handle data access • Provides consistent programming interface to data sources • MVC • Database access handled in DataRepository • Controller calls repository methods • Next: SQL Server Express • Creating databases & using with ASP.NET