sofia, bulgaria | 9-10 october datasets, business objects or just linq sahil malik prerequisites...

40
Sofia, Bulgaria | 9-10 October Datasets, Business Objects Datasets, Business Objects or or Just LINQ Just LINQ Sahil Malik Sahil Malik www.winsmarts.com Prerequisites for this presentation: 1) .NET 2) Lots of coffee. Level: Intermediate Sofia, Bulgaria October 10th

Upload: katherine-hawkins

Post on 26-Mar-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October

Datasets, Business Objects or Datasets, Business Objects or Just LINQJust LINQ

Datasets, Business Objects or Datasets, Business Objects or Just LINQJust LINQ

Sahil MalikSahil Malikwww.winsmarts.com

Prerequisites for this presentation:

1) .NET 2) Lots of coffee.

Level: Intermediate

Sofia, Bulgaria

October 10th

Page 2: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

A little bit about me.A little bit about me.A little bit about me.A little bit about me.

● MVP C#

● INETA Speaker

● telerik Evangelist

● Book Author X 3

● Article Author X n

● Site: ● www.winsmarts.com

● Blog: ● blah.winsmarts.com

● MVP C#

● INETA Speaker

● telerik Evangelist

● Book Author X 3

● Article Author X n

● Site: ● www.winsmarts.com

● Blog: ● blah.winsmarts.com

Page 3: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

A bit about what I will talk A bit about what I will talk about ..about ..A bit about what I will talk A bit about what I will talk about ..about ..

● This presentation is all about practical tips, technology applied rather than technology presented.

● The case for disconnected data

● Mechanisms to represent disconnected data

●DataSets and Business Objects

● Stand in .NET 2.0, and compare the two

●Code Examples.

● And what happens when you throw the future in the mix?

● This presentation is all about practical tips, technology applied rather than technology presented.

● The case for disconnected data

● Mechanisms to represent disconnected data

●DataSets and Business Objects

● Stand in .NET 2.0, and compare the two

●Code Examples.

● And what happens when you throw the future in the mix?

Page 4: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

The two halves of data accessThe two halves of data accessThe two halves of data accessThe two halves of data access

Page 5: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

The ConnectedThe ConnectedThe ConnectedThe Connected

● Pessimistic Concurrency.

● Keeping a connection open – while u wait !!

● A much lower possibility of concurrency conflicts.

● Simpler/More Straightforward.

● Pessimistic Concurrency.

● Keeping a connection open – while u wait !!

● A much lower possibility of concurrency conflicts.

● Simpler/More Straightforward.

Page 6: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

The Connected – Lets be Practical!The Connected – Lets be Practical!The Connected – Lets be Practical!The Connected – Lets be Practical!

● If amazon.com maintained an open database connection, for every visitor on their site.

●About 40 million visitors a day

●At an average, lets assume that each visitor were to stay online for 5 minutes.

●Lets to be fair, assume, no connection pooling.

● If amazon.com maintained an open database connection, for every visitor on their site.

●About 40 million visitors a day

●At an average, lets assume that each visitor were to stay online for 5 minutes.

●Lets to be fair, assume, no connection pooling.

Page 7: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Connected – GEE WHIZ!!Connected – GEE WHIZ!!Connected – GEE WHIZ!!Connected – GEE WHIZ!!

● Total number of average open connections

●40,000,000 / (24 * 60/5) = 312,500

● Total licensing cost on an Oracle database –

●Ouch amount of $.

● Total licensing cost on SQL Server –

●Also an Ouch amount of $.

● And don’t forget the nuclear power plant to run your servers.

● Total number of average open connections

●40,000,000 / (24 * 60/5) = 312,500

● Total licensing cost on an Oracle database –

●Ouch amount of $.

● Total licensing cost on SQL Server –

●Also an Ouch amount of $.

● And don’t forget the nuclear power plant to run your servers.

Page 8: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Connected – But it’s not just Connected – But it’s not just about $about $Connected – But it’s not just Connected – But it’s not just about $about $

● What about a distributed architecture?

● Web Services?

● Disconnected Salesman?

● The whole UDDI concept – a.k.a. Microsoft and IBM’s idea for World “Piece”.

● What about a distributed architecture?

● Web Services?

● Disconnected Salesman?

● The whole UDDI concept – a.k.a. Microsoft and IBM’s idea for World “Piece”.

Page 9: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

DisconnectedDisconnectedDisconnectedDisconnected

● Connect

● Read

● Disconnect

●Others may use your connection.

● Work on your data

● Re Connect

● Submit Changes

● Disconnect

● Connect

● Read

● Disconnect

●Others may use your connection.

● Work on your data

● Re Connect

● Submit Changes

● Disconnect

Page 10: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Demo #1Demo #1Demo #1Demo #1The difference connection pooling makes.The difference connection pooling makes.

Page 11: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Connection PoolingConnection PoolingConnection PoolingConnection Pooling

Page 12: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Disconnected ArchitectureDisconnected ArchitectureDisconnected ArchitectureDisconnected Architecture

Page 13: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Disconnected DataDisconnected DataDisconnected DataDisconnected Data

● Two choices

●Business Objects

●The DataSet family.

● Two choices

●Business Objects

●The DataSet family.

Page 14: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Business Objects - ProsBusiness Objects - ProsBusiness Objects - ProsBusiness Objects - Pros

● A class instance that holds your data, and represents it in a semi structured hierarchical fashion that is specific to your domain.

● You can put “smarts” in your business object.

● Your business object “means” something – it’s not a dumb bucket of data.

● A class instance that holds your data, and represents it in a semi structured hierarchical fashion that is specific to your domain.

● You can put “smarts” in your business object.

● Your business object “means” something – it’s not a dumb bucket of data.

Page 15: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Business Objects - ConsBusiness Objects - ConsBusiness Objects - ConsBusiness Objects - Cons

● You have to write them ● You loose the basic ability to work with

data

●Sorting

●Searching

●Filtering

● Your business objects, are a complete reinvention, in every system you will ever work on.

● You have to write them ● You loose the basic ability to work with

data

●Sorting

●Searching

●Filtering

● Your business objects, are a complete reinvention, in every system you will ever work on.

Page 16: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

The DataSet family - ProsThe DataSet family - ProsThe DataSet family - ProsThe DataSet family - Pros

● Built into the framework.

●You don’t have to write it.

● Comes with a decent ability to search/sort/filter etc.

● You can even add limited smarts to your DataSet by adding partial classes or strongly typing the DataSet.

● Built into the framework.

●You don’t have to write it.

● Comes with a decent ability to search/sort/filter etc.

● You can even add limited smarts to your DataSet by adding partial classes or strongly typing the DataSet.

Page 17: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

The DataSet family - ConsThe DataSet family - ConsThe DataSet family - ConsThe DataSet family - Cons

● “Limited” smarts

●It’s really just a dumb bucket of data.

● Not semi-structured or hierarchical

●Just rows and columns.

● “Limited” smarts

●It’s really just a dumb bucket of data.

● Not semi-structured or hierarchical

●Just rows and columns.

Page 18: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Active BO versus Passive Active BO versus Passive DatasetDatasetActive BO versus Passive Active BO versus Passive DatasetDataset

● Passive●Less work

●Your application keeps your data clean

●Lower impedance mismatch with the database

●Easy SOA, more distributed.

● Passive●Less work

●Your application keeps your data clean

●Lower impedance mismatch with the database

●Easy SOA, more distributed.

● Active●More work

●Your data keeps your application clean

●Higher impedance mismatch with the database

●SOA is tougher, less distributed.

● Active●More work

●Your data keeps your application clean

●Higher impedance mismatch with the database

●SOA is tougher, less distributed.

Page 19: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

DataSet or BO?DataSet or BO?DataSet or BO?DataSet or BO?

● So are you more of a DataSet person? Or a Business Object person?

●WHAT AN AWFUL CHOICE TO MAKE!!

On one hand I loose the ability to validate and represent my data.

On the other, I loose searching/sorting, and have to perform a lot of work translating to and from the underlying data store.

●Which is why I am looking forward to ADO.NET vNext and LINQ.

● So are you more of a DataSet person? Or a Business Object person?

●WHAT AN AWFUL CHOICE TO MAKE!!

On one hand I loose the ability to validate and represent my data.

On the other, I loose searching/sorting, and have to perform a lot of work translating to and from the underlying data store.

●Which is why I am looking forward to ADO.NET vNext and LINQ.

Page 20: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

SO WHAT DOES LINQ*.* GIVE YOU?SO WHAT DOES LINQ*.* GIVE YOU?SO WHAT DOES LINQ*.* GIVE YOU?SO WHAT DOES LINQ*.* GIVE YOU?

Hmmmmm …..Hmmmmm …..

Page 21: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

BEFORE WE ANSWER THATBEFORE WE ANSWER THATBEFORE WE ANSWER THATBEFORE WE ANSWER THAT

Tell me, which car do you like better?Tell me, which car do you like better?

FerrariHonda Civic

Page 22: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

BEFORE WE ANSWER THATBEFORE WE ANSWER THATBEFORE WE ANSWER THATBEFORE WE ANSWER THAT

Tell me, which car do you like better?Tell me, which car do you like better?

Business Objects based Architecture Datasets based

Architecture

Page 23: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

WHAT DOES VNEXT GIVE YOU?WHAT DOES VNEXT GIVE YOU?WHAT DOES VNEXT GIVE YOU?WHAT DOES VNEXT GIVE YOU?vNext = LINQ, LINQ2SQL, LINQ2Dataset, LINQ2Entity, ADO.NET eFvNext = LINQ, LINQ2SQL, LINQ2Dataset, LINQ2Entity, ADO.NET eF

Business Objects based Architecture Datasets based

Architecture

Page 24: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

HOWHOW DOES VNEXT GIVE YOU.. DOES VNEXT GIVE YOU..HOWHOW DOES VNEXT GIVE YOU.. DOES VNEXT GIVE YOU..vNext = LINQ, LINQ2SQL, LINQ2Dataset, LINQ2Entity, ADO.NET eFvNext = LINQ, LINQ2SQL, LINQ2Dataset, LINQ2Entity, ADO.NET eF

Business Objects based Architecture Datasets based

Architecture

Page 25: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

vNextvNextvNextvNext

● .. Makes working with Business Objects easier.

●LINQ

●ADO.NET eF

●LINQ to Entity

●LINQ to SQL

● .. Makes working with Datasets easier.

●LINQ to DataSet

● .. Makes working with Business Objects easier.

●LINQ

●ADO.NET eF

●LINQ to Entity

●LINQ to SQL

● .. Makes working with Datasets easier.

●LINQ to DataSet

Page 26: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Demo #2Demo #2Demo #2Demo #2How LINQ makes working with Business Objects easier.How LINQ makes working with Business Objects easier.

Page 27: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Demo #3Demo #3Demo #3Demo #3LINQ to DataSet – How does that help?LINQ to DataSet – How does that help?

Page 28: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

ADO.NET vNext –high ADO.NET vNext –high level overviewlevel overviewADO.NET vNext –high ADO.NET vNext –high level overviewlevel overview

● It’s about bridging the conceptual and logical model.

● The 4 models

● It’s about bridging the conceptual and logical model.

● The 4 models

PresentationConceptualLogicalPhysical

Page 29: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

ADO.NET vNext –high ADO.NET vNext –high level overviewlevel overviewADO.NET vNext –high ADO.NET vNext –high level overviewlevel overview

Database

Conceptual Schema

/Client Views

Your Business Logic

Page 30: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

ADO.NET vNext –high ADO.NET vNext –high level overviewlevel overviewADO.NET vNext –high ADO.NET vNext –high level overviewlevel overview

● This mapping in done in various XML Files

● This mapping in done in various XML Files

.ssdlLogical Schema

.csdlConceptual Schema

.mslThe

Mapping

Page 31: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

EDM – Entity Data ModelEDM – Entity Data Model

● Entities

● Relationship

● Inheritance

● “is a” relationship when tested against a base entity type.

● Complex Types

● Entities

● Relationship

● Inheritance

● “is a” relationship when tested against a base entity type.

● Complex Types

Page 32: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Logical Schema - ssdlLogical Schema - ssdl

Contact

PK ContactID

FirstName MiddleName LastName EmailAddress Phone

Employee

PK,FK1 EmployeeID

LoginID ManagerID Title BirthDate HireDate SalariedFlag VacationHours SickLeaveHours CurrentFlag

SalesOrder

PK SalesOrderID

FK1 SalesPersonID OrderDate Status OnlineOrderFlag AccountNumber TaxAmt TotalDue

SalesPerson

PK,FK1 SalesPersonID

SalesQuota Bonus SalesYTD SalesLastYear

Page 33: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Conceptual Schema - csdlConceptual Schema - csdl

SalesPeople (EntitySet)SalesOrders (EntitySet)

SalesOrder (EDM type)

PK ID

OrderDate Status AccountNumber TotalDue

StoreSalesOrder (EDM type)

Tax

SalesPerson (EDM type)

PK ID

SalesQuota Bonus SalesYTD HireDate Title FirstName MiddleName LastName ContactInformation

SalesPerson_Order Association

Page 34: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Mapping - mslMapping - msl

Contact

PK ContactID

FirstName MiddleName LastName EmailAddress Phone

Employee

PK,FK1 EmployeeID

LoginID ManagerID Title BirthDate HireDate SalariedFlag VacationHours SickLeaveHours CurrentFlag

SalesPeople (EntitySet)

SalesOrders (EntitySet)

SalesOrder (EDM type)

PK ID

OrderDate Status AccountNumber TotalDue

StoreSalesOrder (EDM type)

Tax

SalesPerson (EDM type)1

PK ID

SalesQuota Bonus SalesYTD HireDate Title FirstName MiddleName LastName ContactInformation

SalesPerson_Order Association

SalesOrder

PK SalesOrderID

FK1 SalesPersonID OrderDate Status OnlineOrderFlag AccountNumber TaxAmt TotalDue

SalesPerson

PK,FK1 SalesPersonID

SalesQuota Bonus SalesYTD SalesLastYear

Page 35: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

What about DLINQ?What about DLINQ?What about DLINQ?What about DLINQ?

● It’s called LINQ to SQL now

● You can use it where the logical model and the conceptual model are the same.

● Further Reading

● ADO.NET vNext CTP http://shrinkster.com/i5y

● DLINQ and LINQ http://shrinkster.com/i5x

● It’s called LINQ to SQL now

● You can use it where the logical model and the conceptual model are the same.

● Further Reading

● ADO.NET vNext CTP http://shrinkster.com/i5y

● DLINQ and LINQ http://shrinkster.com/i5x

Page 36: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

A bit about release datesA bit about release datesA bit about release datesA bit about release dates

.NET 2.0

.NET 3.0WF/WCF/WPF/Cardspace

SharePoint 2007Vista

All this stuffOrcas, .NET vNext, ADO.NET vNext, LINQ *.*

CLR 2.0

Nov 2005Nov 2005 End 2006ishEnd 2006ish FutureFuture

Page 37: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Clearing a few misconceptionsClearing a few misconceptions

● ADO.NET vNext is unlike other ORMs in the market place.

● Minimalist approach, rather than everything and the kitchen sink.

● ADO.NET vNext introduces the concept of “Client Views” and thus “set based theory” in object oriented code.

● Queries are more sophisticated than simple string matching

● It takes the approach of attacking the conceptual model, rather than get mired in object to relational translation.

● ADO.NET vNext is unlike other ORMs in the market place.

● Minimalist approach, rather than everything and the kitchen sink.

● ADO.NET vNext introduces the concept of “Client Views” and thus “set based theory” in object oriented code.

● Queries are more sophisticated than simple string matching

● It takes the approach of attacking the conceptual model, rather than get mired in object to relational translation.

Page 38: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Demo #4Demo #4Demo #4Demo #4LINQ to Entity, ADO.NET vNext – How do they help, (and not help).LINQ to Entity, ADO.NET vNext – How do they help, (and not help).

Page 39: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October

Page 40: Sofia, Bulgaria | 9-10 October Datasets, Business Objects or Just LINQ Sahil Malik  Prerequisites for this presentation: 1).NET 2) Lots

Sofia, Bulgaria | 9-10 October