SlideShare uma empresa Scribd logo
1 de 32
MySQL, LINQ and the ADO.NET Entity Framework ,[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Working with DataSets ,[object Object],//Execute a query, retrieve and store the results connectionString =  "Data Source=localhost;User ID=...;" ; commandText =  "SELECT CompanyName, City FROM Customers "  + "WHERE Country = ?Country" ; adapter =  new  MySqlDataAdapter (commandText, connectionString); adapter.SelectCommand.Parameters.AddWithValue( "?Country", "Brazil"); table =  new  DataTable (); adapter.Fill(table); //Display the results DataGridView  resultsGrid =  new  DataGridView (); resultsGrid.DataSource = table; //Submit pending changes commandBuilder =  new  MySqlCommandBuilder (adapter); adapter.Update(table);
Working with DataSets ,[object Object],[object Object],[object Object],[object Object],[object Object]
Moving to data access layers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Moving to data access layers ,[object Object],//Partial class to separate data access code public class  Customer  { //Add methods to return data public static  List < Customer >  GetCustomers ( string   country) { List < Customer > results =  new  List < Customer >   (); MySqlConnection  connection =  new  MySqlConnection (connectString); connection.Open(); MySqlCommand  command =  new  MySqlCommand (queryString, connection);  command.Parameters.AddWithValue( &quot;?Country&quot; , country); MySqlDataReader  reader = command.ExecuteReader(); while (reader.Read()) results.Add( Customer .CreateFromReader(reader)); return  results; } //Support tracking and submitting changes private string  origCustomerId, origCompanyName, ...; public void  SubmitChanges() { ... } }
Moving to data access layers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introducing LINQ ,[object Object],[object Object],[object Object],[object Object]
Introducing LINQ ,[object Object],//Create an array of integers int [] myarray =  new   int [] { 49, 28, 20, 15, 25, 23, 24, 10, 7, 34 }; //Create a query for odd numbers var  oddNumbers =  from  i  in  myarray  where  i % 2 == 1 select  i; //Display the results of the query foreach  ( int  i  in  oddNumbers) Console .WriteLine(i); //Create a query for odd numbers, sorted var  oddNumbers =  from  i  in  myarray  where  i % 2 == 1 orderby  i select  i; //Create a query for odd numbers, sorted in descending order var  oddNumbers =  from  i  in  myarray  where  i % 2 == 1 orderby  i  descending  select  i; //Create a query for odd numbers var  oddNumbers =  from  i  in  myarray  where  i % 2 == 1  select  i; //Compose the original query to create a query for odd numbers var  sorted =  from  i  in  oddNumbers  orderby  i  descending select  i;
LINQ-enabled classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
LINQ to DataSet ,[object Object],[object Object],Dim  ordersQuery =  From  o  In  dataSet.Orders _ Where  o.CustomerID =  &quot;ALFKI&quot;  _ Select  o For   Each  o  As  NorthwindDataSet.OrdersRow  In  ordersQuery Console.WriteLine( &quot;{0}  {1,10:d}&quot; , _ o.OrderID, o.OrderDate) Next  o
LINQ to DataSet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
LINQ to SQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],LINQ to Entities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
LINQ to DataSet ,[object Object],[object Object],Dim  ordersQuery =  From  o  In  dataSet.Orders _ Where  o.CustomerID =  &quot;ALFKI&quot;  _ Select  o For   Each  o  As  NorthwindDataSet.OrdersRow  In  ordersQuery Console.WriteLine( &quot;{0}  {1,10:d}&quot; , _ o.OrderID, o.OrderDate) Next  o
LINQ to Entities or LINQ to SQL? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
LINQ to Entities: Generating Queries ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Entity Framework: LINQ and more ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],ADO.NET Provider EntityClient ObjectServices LINQ to Entities
Entity Framework Query Options ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],var  ordersQuery =  from  o  in  context.Orders where  o.Customers.CustomerID ==  &quot;ALFKI&quot; select  o; foreach  ( var  o  in  ordersQuery) Console .WriteLine( &quot;{0}  {1:d}&quot; , o.OrderID, o.OrderDate);
Entity Framework Query Options ,[object Object],[object Object],[object Object],[object Object],[object Object],Dim  eql  As String  =  &quot;SELECT VALUE o FROM Orders AS o &quot;  & _ &quot;  WHERE o.Customer.CustomerID = 'ALFKI'&quot; Dim  ordersQuery = context.CreateQuery( Of  Order)(esql) For Each  o  As  Order  In  ordersQuery Console.WriteLine( &quot;{0}  {1,10:d} &quot; , o.OrderID, o.OrderDate) Next  o
Entity Framework Query Options ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],string  eSql =  &quot;SELECT VALUE o FROM NorthwindEntities.Orders AS o &quot;  + &quot;WHERE o.Customers.CustomerID = 'ALFKI'&quot; ; EntityCommand  cmd =  new   EntityCommand (eSql, connectionString); EntityDataReader  rdr = cmd.ExecuteReader(); while  (rdr.Read()) Console .WriteLine( &quot;{0} {1:d}&quot; , rdr[ &quot;OrderID&quot; ], rdr[ &quot;OrderDate&quot; ]);
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ADO.NET Data Services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ADO.NET Data Services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary - LINQ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary - ADO.NET Entity Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary - ADO.NET Data Services ,[object Object],[object Object],[object Object],[object Object],[object Object]
Questions?

Mais conteúdo relacionado

Mais procurados

Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
Confiz
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
Doncho Minkov
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
SharePoint Saturday NY
 
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.02005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
Daniel Fisher
 
Data Access Mobile Devices
Data Access Mobile DevicesData Access Mobile Devices
Data Access Mobile Devices
venkat987
 
Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...
Shakir Majeed Khan
 

Mais procurados (20)

Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
70 562
70 56270 562
70 562
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Olap
OlapOlap
Olap
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
 
6.2\9 SSIS 2008R2_Training - DataFlow Transformations
6.2\9 SSIS 2008R2_Training - DataFlow Transformations6.2\9 SSIS 2008R2_Training - DataFlow Transformations
6.2\9 SSIS 2008R2_Training - DataFlow Transformations
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.02005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
2005 - .NET Chaostage: 1st class data driven applications with ASP.NET 2.0
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
 
Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterprise
 
Let's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureLet's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architecture
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
6.1\9 SSIS 2008R2_Training - DataFlow Transformations
6.1\9 SSIS 2008R2_Training - DataFlow Transformations6.1\9 SSIS 2008R2_Training - DataFlow Transformations
6.1\9 SSIS 2008R2_Training - DataFlow Transformations
 
Entity Framework - Queries
Entity Framework -  QueriesEntity Framework -  Queries
Entity Framework - Queries
 
Data Access Mobile Devices
Data Access Mobile DevicesData Access Mobile Devices
Data Access Mobile Devices
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)Entity Framework - Entity Data Model (edm)
Entity Framework - Entity Data Model (edm)
 
Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...
 

Semelhante a B_110500002

What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
ukdpe
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
Quek Lilian
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
Luis Enrique
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
google
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
Igor Moochnick
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
grenaud
 

Semelhante a B_110500002 (20)

What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
 
Linq
LinqLinq
Linq
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
Practical OData
Practical ODataPractical OData
Practical OData
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Silverlight & WCF RIA
Silverlight & WCF RIASilverlight & WCF RIA
Silverlight & WCF RIA
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
Mobile
MobileMobile
Mobile
 
ADO.NET Data Services
ADO.NET Data ServicesADO.NET Data Services
ADO.NET Data Services
 
Work with data in ASP.NET
Work with data in ASP.NETWork with data in ASP.NET
Work with data in ASP.NET
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

B_110500002

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.