var context = new CustomerContext(); //... context code...



Similar documents
ASP.NET Programming with C# and SQL Server

The Data Access Handbook

ITDUMPS QUESTION & ANSWER. Accurate study guides, High passing rate! IT dumps provides update free of charge in one year!

and what does it have to do with accounting software? connecting people and business

SnapLogic Salesforce Snap Reference

Introduction to SQL for Data Scientists

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

MySQL for Beginners Ed 3

HareDB HBase Client Web Version USER MANUAL HAREDB TEAM

A basic create statement for a simple student table would look like the following.

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

Programming in C# with Microsoft Visual Studio 2010

Intro to Databases. ACM Webmonkeys 2011

Assignment 3 Version 2.0 Reactive NoSQL Due April 13

DBMS / Business Intelligence, SQL Server

SQL, PL/SQL FALL Semester 2013

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

SSIS Training: Introduction to SQL Server Integration Services Duration: 3 days

Database Optimization for Web Developers. Little things that make a big difference

Toad for Oracle 8.6 SQL Tuning

Multimedia im Netz Online Multimedia Winter semester 2015/16

1Z0-117 Oracle Database 11g Release 2: SQL Tuning. Oracle

CS 564: DATABASE MANAGEMENT SYSTEMS

Getting Started with Telerik Data Access. Contents

CSC 443 Data Base Management Systems. Basic SQL

Conquer the 5 Most Common Magento Coding Issues to Optimize Your Site for Performance

SQL Server Instance-Level Benchmarks with DVDStore

Deleting A Record Updating the Database Binding Data Tables to Controls Binding the Data Table to the Data Grid View...

Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

v1.1.0 SimpleSQL SQLite manager for Unity3D echo17.com

System Services. Engagent System Services 2.06


Bubble Code Review for Magento

VB.NET - DATABASE ACCESS

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

PROCESSES LOADER 9.0 SETTING. Requirements and Assumptions: I. Requirements for the batch process:

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

ASP.NET Using C# (VS2012)

Execution Plans: The Secret to Query Tuning Success. MagicPASS January 2015

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

8- Management of large data volumes

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

Supporting Data Set Joins in BIRT

70-487: Developing Windows Azure and Web Services

Whitepaper: performance of SqlBulkCopy

Database Query 1: SQL Basics

When a variable is assigned as a Process Initialization variable its value is provided at the beginning of the process.

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

T-SQL STANDARD ELEMENTS

Web Development using PHP (WD_PHP) Duration 1.5 months

Database Administration with MySQL

A Brief Introduction to MySQL

Database Programming with C# CARSTEN THOMSEN

NUTECH COMPUTER TRAINING INSTITUTE 1682 E. GUDE DRIVE #102, ROCKVILLE, MD 20850

Building ASP.NET Applications

Chapter 9, More SQL: Assertions, Views, and Programming Techniques

HIGH PERFORMANCE PROGRAMMING FOR SHAREPOINT DEVELOPERS. DEV213 Eric Shupps, Microsoft MVP [SharePoint]

MariaDB Cassandra interoperability

David Dye. Extract, Transform, Load

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

Raima Database Manager Version 14.0 In-memory Database Engine

PUBLIC Performance Optimization Guide

Module 1: Getting Started with Databases and Transact-SQL in SQL Server 2008

Data Integrator Performance Optimization Guide

Package sjdbc. R topics documented: February 20, 2015

OPTIMIZING QUERIES IN SQL SERVER 2008

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

Geodatabase Programming with SQL

Serious Threat. Targets for Attack. Characterization of Attack. SQL Injection 4/9/2010 COMP On August 17, 2009, the United States Justice

PHP Language Binding Guide For The Connection Cloud Web Services

INSTALLING, CONFIGURING, AND DEVELOPING WITH XAMPP

>

ADOBE AIR. Working with Data in AIR. David Tucker

Resco CRM Server Guide. How to integrate Resco CRM with other back-end systems using web services


database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

AWS Schema Conversion Tool. User Guide Version 1.0

LearnFromGuru Polish your knowledge

High-Performance Oracle: Proven Methods for Achieving Optimum Performance and Availability

Setting Up ALERE with Client/Server Data

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

In this session, we use the table ZZTELE with approx. 115,000 records for the examples. The primary key is defined on the columns NAME,VORNAME,STR

Talking to Databases: SQL for Designers

Introduction to IR Systems: Supporting Boolean Text Search. Information Retrieval. IR vs. DBMS. Chapter 27, Part A

Overview. Physical Database Design. Modern Database Management McFadden/Hoffer Chapter 7. Database Management Systems Ramakrishnan Chapter 16

Partitioning under the hood in MySQL 5.5

SQL. Short introduction

SQLITE C/C++ TUTORIAL

Why do statisticians need to know about databases?

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 03 (Nebenfach)

Using IRDB in a Dot Net Project

MySQL Storage Engines

CSCC09F Programming on the Web. Mongo DB

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

relational database tables row column SQL

TMS RemoteDB Documentation

Improving SQL Server Performance

JDBC (Java / SQL Programming) CS 377: Database Systems

Transcription:

.NET Entity Framework Extensions >.NET Entity Framework Extension What's Entity Framework Extensions? The library enhances and optimizes Entity Framework's performance by using bulk operations. var context = new CustomerContext(); //... context code... // Save entities in Bulk to increase SaveChanges performance context.bulksavechanges(); // Perform specific bulk operations context.bulkdelete(customers); context.bulkinsert(customers); context.bulkupdate(customers); context.bulkmerge(customers); // Customize operations for performance tuning context.bulksavechanges(operation => operation.batchsize = 100); // Scalable customization such as primary key context.bulkmerge(customers, operation => { operation.columnprimarykeyexpression = customer => customer.code; http://www.zzzprojects.com 1 ZZZ Projects Inc.

.NET Entity Framework Extensions > BulkSaveChanges Method BulkSaveChanges INSERT entities in a database table or a view. var context = new CustomerContext(); //... context code... context.bulksavechanges(); // Customize operation context.bulksavechanges(operation => operation.batchsize = 100); http://www.zzzprojects.com 2 ZZZ Projects Inc.

.NET Entity Framework Extensions > Bulk Operations Methods BulkInsert INSERT entities in a database table or a view. BulkUpdate UPDATE entities in a database table or a view. BulkDelete DELETE entities in a database table or a view. BulkMerge UPSERT operation. INSERT new entities and UPDATE entities matching the primary key in a database table or a view. context.bulkinsert(customers); // Customize operation. context.bulkinsert(customers, operation => { operation.batchsize = 100; context.bulkupdate(customers); // Customize operation. context.bulkupdate(customers, operation => { operation.batchsize = 100; operation.columnprimarykeyexpression = customer => customer.code; context.bulkdelete(customers); // Customize operation. context.bulkdelete(customers, operation => { operation.batchsize = 100; operation.columnprimarykeyexpression = customer => customer.code; context.bulkmerge(customers); // Customize operation. context.bulkmerge(customers, operation => { operation.batchsize = 100; operation.columnprimarykeyexpression = customer => customer.code; http://www.zzzprojects.com 3 ZZZ Projects Inc.

.NET Entity Framework Extensions > FromQuery Methods DeleteFromQuery DELETE rows in a database table or a view using Lambda Expressions without loading entities in the DbContext. UpdateFromQuery UPDATE rows in a database table or a view using Lambda Expressions without loading entities in the DbContext. var context = new CustomerContext(); // DELETE all customers that are inactive for more than 2 years context.customers.where(x => x.lastlogin < DateTime.Now.AddYears(-2)).DeleteFromQuery(); // Customize operation context.customers.where(x => x.lastlogin < DateTime.Now.AddYears(-2)).DeleteFromQuery(operation => operation.batchsize = 100); // UPDATE all customers that are inactive for more than 2 years // SET status active to false context.customers.where(x => x.actif && x.lastlogin < DateTime.Now.AddYears(-2)).UpdateFromQuery(x => new Customer {Actif = false http://www.zzzprojects.com 4 ZZZ Projects Inc.

.NET Entity Framework Extensions > Caching FromMemoryCache Cache and retrieve entities from the memory cache. // Load entities from the database once, // Then load entities from Memory cache for subsequent calls. var states = context.states.where(x => x.actif).frommemorycache(); // Customize caching settings such as key to use. var statesactif = context.states.where(x => x.actif).frommemorycache("states_actif"); FromSessionCache Cache and retrieve entities from the session cache. FromHttpRequestCache Cache and retrieve entities from the HttpRequest cache. FromHttpRuntimeCache Cache and retrieve entities from the HttpRuntime cache. var states = context.states.where(x => x.actif).fromsessioncache(); var states = context.states.where(x => x.actif).fromhttprequestcache(); var states = context.states.where(x => x.actif).fromhttpruntimecache(null, DateTime.Now.AddHours(1), TimeSpan.Zero, CacheItemPriority.Default, null); http://www.zzzprojects.com 5 ZZZ Projects Inc.

.NET Entity Framework Extensions > Execute Methods ExecuteDataSet Execute a SQL statement and return all results sets in a DataSet. var sql = "SELECT * FROM Customer WHERE Actif = @IsActif"; // Customizing command with parameters. var ds = context.database.executedataset(command => { command.commandtext = sql; var parameter = command.createparameter(); parameter.parametername = "@IsActif"; parameter.value = true; ExecuteDataTable Execute a SQL statement and return a DataTable. ExecuteEntity<TEntity> Execute a SQL statement and return a TEntity. ExecuteEntities<TEntity> Execute a SQL statement and return a List<TEntity>. ExecuteEntityWithMapping<TEntity> Execute a SQL statement and return a TEntity using Entity Framework Mapping. ExecuteEntitiesWithMapping<TEntity> Execute a SQL statement and return a List<TEntity> using Entity Framework Mapping. ExecuteExpandoObject Execute a SQL statement and return an ExpandoObject. ExecuteExpandoObjects Execute a SQL statement and return a List<ExpandoObject>. command.parameters.add(parameter); var sql = "SELECT * FROM Customer"; var dt = context.database.executedatatable(sql); var sql = "SELECT TOP 1 * FROM Customer"; Customer entity = context.database.executeentity<customer>(sql); var sql = "SELECT * FROM Customer"; List<Customer> entities = context.database.executeentities<customer>(sql); var sql = "SELECT TOP 1 * FROM Customer"; Customer entity = context.database.executeentitywithmapping<customer>(sql); var sql = "SELECT * FROM Customer"; List<Customer> entities = context.database.executeentitieswithmapping<customer>(sql); var sql = "SELECT TOP 1 * FROM Customer"; ExpandoObject expandoobject = context.database.executeexpandoobject(sql); var sql = "SELECT * FROM Customer"; List<ExpandoObject> expandoobjects = context.database.expandoobjects(sql); http://www.zzzprojects.com 6 ZZZ Projects Inc.

.NET Entity Framework Extensions > Execute Methods ExecuteNonQuery Execute a SQL statement and return the number of rows affected. ExecuteReader Execute a SQL Statement and perform an action on the DataReader. ExecuteScalar Execute a SQL statement and return an object. ExecuteScalarAs<TValue> Execute a SQL statement and return a TValue using cast. ExecuteScalarTo<TValue> Execute a SQL statement and return a TValue using convert. ExecuteXmlReader Execute a SQL statement and return a XmlReader. var sql = "DELETE FROM Customer"; int rowaffected = context.database.executenonquery(sql); var sql = "SELECT COUNT(1) FROM Customer"; context.database.executereader(sql, reader => { while (reader.read()) { //... code... } var sql = "SELECT COUNT(1) FROM Customer"; object value = context.database.executescalar(sql); var sql = "SELECT COUNT(1) FROM Customer"; int value = context.database.executescalaras<int>(sql); var sql = "SELECT COUNT(1) FROM Customer"; int value = context.database.executescalarto<int>(sql); var sql = "SELECT * FROM Customer"; XmlReader reader = context.database.executexmlreader(sql); http://www.zzzprojects.com 7 ZZZ Projects Inc.

.NET Entity Framework Extensions > Extension Methods Database Retrieve the model behind the context at runtime. var database = new CustomerContext().Database; // Get Context var context = database.getcontext<customercontext>(); var dbcontext = database.getdbcontext(); // Get Connection var connection = database.getconnection<sqlconnection>(); var entityconnection = database.getentityconnection(); DbContext Get a specific entity from the model. // Get Transaction var transaction = database.gettransaction<sqltransaction>(); var dbtransaction = database.getdbtransaction(); var entitytransaction = database.getentitytransaction(); var dbcontext = new CustomerContext(); // Get Model var model = dbcontext.getmodel(); // Get Context var objectcontext = dbcontext.getobjectcontext(); DbSet Get a specific property from an entity. // Convert ToData var ds = dbcontext.todataset(customers); var dt = dbcontext.todatatable(customers); var dbcontext = new CustomerContext(); // Add or Update entities dbcontext.customers.addorupdateextension(customer => customer.code, customers); http://www.zzzprojects.com 8 ZZZ Projects Inc.

.NET Entity Framework Extensions > Extension Methods EntityTransaction Get a specific property from an entity. IQueryable Get a specific property from an entity. ObjectContext Get a specific property from an entity. var entitytransaction = new CustomerContext().Database.GetEntityTransaction(); // Get Transaction var transaction = entitytransaction.gettransaction<sqltransaction>(); var dbtransaction = entitytransaction.getdbtransaction(); var query = new CustomerContext().Customers.Where(x => x.actif); // Get Context var context = query.getcontext(); var objectcontext = new CustomerContext().GetObjectContext(); // Get Context var dbcontext = objectcontext.getdbcontext(); http://www.zzzprojects.com 9 ZZZ Projects Inc.

.NET Entity Framework Extensions > Runtime Model GetModel Retrieve the model behind the context at runtime. Entity<TEntity> Get a specific entity from the model. Property Get a specific property from an entity. var context = new CustomerContext(); // GET model var model = context.getmodel(); var model = context.getmodel(); // GET entity and meta var customer = model.entity<customer>(); var basetype = customer.info.basetype; var istpc = customer.info.istpc; var model = context.getmodel(); var customer = model.entity<customer>(); // GET property and meta var name = customer.property(x => x.name); var ismandatory =!name.nullable; var isprimarykey = name.isprimarykey; var length = name.maxlength; http://www.zzzprojects.com 10 ZZZ Projects Inc.

.NET Entity Framework Extensions > Specialized Database SqlDatabase Get a SQL Server database instance for the context. var context = new CustomerContext(); var sql = "SELECT * FROM Customer WHERE Actif = @IsActif"; // Use specialized database to use specific class instead of abstract class var dt = context.sqldatabase().executedatatable(sql, new[] {new SqlParameter("@IsActif", true) SqlCeDatabase Get a SQL Compact database instance for the context. MySqlDatabase Get a MySQL database instance for the context. SQLiteDatabase Get a SQLite database instance for the context. // Customize command var dt2 = context.sqldatabase().executedatatable(command => { command.commandtext = sql; command.parameters.add(new SqlParameter("@IsActif", true)); var dt = context.sqlcedatabase().executedatatable(sql, new[] {new SqlCeParameter("@IsActif", true) var dt = context.mysqldatabase().executedatatable(sql, new[] {new MySqlParameter("@IsActif", true) var dt = context.sqlitedatabase().executedatatable(sql, new[] {new SQLiteParameter("@IsActif", true) http://www.zzzprojects.com 11 ZZZ Projects Inc.