SlideShare une entreprise Scribd logo
1  sur  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?

Contenu connexe

Tendances

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
 

Tendances (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...
 

Similaire à 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
 

Similaire à 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
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

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.