Upload
others
View
12
Download
0
Embed Size (px)
Citation preview
1 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
2 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Entity Framework, LINQ, and WCF Data
Services for Oracle Database
Alex Keh
Principal Product Manager, Oracle
3 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
4 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Program Agenda
• Entity Framework and LINQ
– General Concepts and Functionality
– Oracle Support for Entity Framework and LINQ
• WCF Data Services and OData
5 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
ADO.NET Entity Framework
• Object-relational mapper (ORM) for .NET
– Abstracts the logical (relational) database schema
– Presents schema in an application-specific conceptual schema
– Eliminates object-relational impedance mismatch
– NHibernate – another popular ORM for .NET
• Data source providers abstract DB interfaces when
programming against conceptual model
6 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
ADO.NET Entity Framework
• Entity data model (EDM) – conceptual data model that
maps to the relational model
• Entities represent the individual object instances
– E.g. employees, sales orders
• EDM Wizard and Designer
– Generating and modifying DB and conceptual schema mapping
7 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Querying and Modifying Entities
• Query entities via alternative language to SQL
• LINQ to Entities
– Language-Integrated Query (LINQ)
– Query language integrated into .NET
– E.g. “from e in ctx.EMPs select e”
8 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Querying and Modifying Entities
• Entity SQL
– SQL variant for declarative queries and updates over entities and
their relationships
– Uses EntityClient classes to query
– E.g. “select value e from Entities.EMPs as e”
• DML
– Stored procedures
– SaveChanges method on ObjectContext
9 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Entity Framework Architecture
10 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Entity Data Model Wizard and Designer
– Generate a conceptual model from Oracle Database
– Update conceptual model, storage model, and mappings from
Oracle Database
– Generate Oracle SQL DDL script from the conceptual model
11 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Query language interfaces
– LINQ to Entities
– Entity SQL
– DML capabilities (insert/update/delete)
• Entity Framework auto-generates DML statements for Oracle
Database
• Or use your own Oracle stored procedures for DML
12 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
D E M O N S T R A T I O N
Entity Framework and LINQ
13 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• All standard ADO.NET APIs supported using ODP.NET
– Use EntityClient or ObjectContext
• No ODP.NET-specific APIs available, except…
– Settings available in the Registry or .NET config files including
ODP.NET connection string attributes
– E.g. FetchSize, SelfTuning, DllPath, Max Pool Size, HA Events,
Load Balancing, etc.
14 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Function imports
– Define .NET methods that map to stored procedures
– Add Function Import dialog integration
15 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Return implicit result sets
– Use REF CURSORs from stored procedures
– Available to both EF and non-EF scenarios
• EF: one result set per stored procedure
• Non-EF: one or more result set per stored procedure
– Return types
• Complex – read-only
• Entity – read and updatable
– Define result set bind and metadata info in .NET config file
16 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
D E M O N S T R A T I O N
Function Import and Implicit Result Set
17 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Return stored procedure scalar values
– Bind directly to stored procedure
– Only bind by name supported, not bind by position
– No .NET config changes necessary
// C#
ObjectParameter oparam = new ObjectParameter(“oparam", typeof(decimal));
18 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Triggers and sequences
– Set StoreGeneratedPattern=“Identity” manually in SSDL
• Model/Schema generation
– Database-First
– Model-First
– Code-First – TBD
19 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
D E M O N S T R A T I O N
Model-First
20 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Oracle Support for LINQ and Entity Framework
• Requires .NET Framework 4 and Visual Studio 2010
• Time frame
– Beta: now available
– Production: Around end of 2011
• Availability will be announced via Twitter and Oracle
.NET newlsetter
– Twitter: @OracleDOTNET
– Newsletter: http://otn.oracle.com/dotnet
21 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Program Agenda
• Entity Framework and LINQ
• WCF Data Services and OData
22 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
WCF Data Services and OData
• WCF Data Services
– Platform for exposing data via web services and REST
– Accessed over HTTP with a URI to return data
– Represented as EDM objects
• Open Data Protocol (OData)
– Protocol for sharing data
– Allows a multitude of data consumers to interoperate with a
multitude of data producers
23 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
D E M O N S T R A T I O N
WCF Data Services and OData
24 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
More Oracle .NET Resources
• OTN .NET Developer Center
– http://otn.oracle.com/dotnet
• For more questions
25 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
Q&A
26 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
26 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
The preceding is intended to outline our general product direction.
It is intended for information purposes only, and may not be
incorporated into any contract. It is not a commitment to deliver
any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and
timing of any features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.
27 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.
28 Copyright © 2011, Oracle and/or its affiliates. All rights
reserved.