3/10/2012

Even Better Access to Team Foundation Server

Starting today, Microsoft is eliminating the requirement to purchase Team Explorer Everywhere separately.  Before today, Team Explorer Everywhere users had to purchase both a Client Access License (CAL) and the Team Explorer Everywhere software, whereas Visual Studio Team Explorer users only had to purchase a CAL – the Visual Studio Team Explorer software has always been a free download (TE 2008, TE 2010, TE 11 Beta) for users who had a license to access a TFS server.  Starting today the story is the same for Team Explorer Everywhere (TEE 2010 with SP1, TEE 11 Beta). See bharry's WebLog for more details.

3/08/2012

SQL Server 2012 Released

Yesterday, SQL Server 2012 was released. The Relased To Manufacturing version is available for download to MSDN subscribers already. For more details, see The Microsoft SQL Server website.

1/30/2012

SQL Server Data Tools available

Microsoft has just released SQL Server Data Tools. SQL Server Data Tools provides an integrated environment for database developers to carry out all their database design work for any SQL Server platform (both on and off premise) within Visual Studio. Database developers can use the SQL Server Object Explorer in VS to easily create or edit database objects and data, or execute queries.

Got to SQL Server Data Tools for more details. Update: A new update is available. Where the initial release used SQL Server 2012 RC0 components, now it includes SQL Server 2012 RTM components.

1/25/2012

The new Analytic functions in SQL Server 2012 - SQLServerCentral

Analytic Functions

It’s hard to describe the overall purpose of the analytic functions better than how Books Online (BOL) does: “Analytic functions compute an aggregate value based on a group of rows. However, unlike aggregate functions, they can return multiple rows for each group. You can use analytic functions to compute moving averages, running totals, percentages or top-N results within a group.”

SQL Server 2012 adds eight analytic functions, all of which require the use of the OVER clause. These are LAG, LEAD, FIRST_VALUE, LAST_VALUE, CUME_DIST, PERCENT_RANK, PERCENTILE_CONT, and PERCENTILE_DISC. Ther article referenced below will look at each one of these in more detail.

The new Analytic functions in SQL Server 2012 - SQLServerCentral

1/24/2012

New book: XAML Developer Reference - Microsoft Press - Site Home - MSDN Blogs

Microsoft has announced that the new Microsoft Press book XAML Developer Reference (ISBN 978-0-7356-5896-7, 340 pages), is now available for purchase.

This book covers XAML from the ground up for both Windows Presentation Foundation and Silverlight development—and of course, because XAML is a foundational technology in building Windows 8 applications, learning the information here will be useful for a long time to come.

You’ll discover practical ways to build rich, interactive user interfaces with data integration capabilities and support for multimedia, graphics, and animation. This hands-on guide is ideal for Microsoft .NET developers and web designers alike.

Written by two XAML experts, Mamta Dalal and Ashish Ghoda, this book covers all the basic XAML elements, their properties and event systems, use of templates, positioning, 2D and 3D graphics, markup extensions, data binding, and much more.

The complete Chapter 4, “Markup Extensions and Other Features,” can be read from the link below, for getting a good feel for the level of detail in this book.

New book: XAML Developer Reference - Microsoft Press - Site Home - MSDN Blogs

1/11/2012

RTM’d today: Microsoft Manual of Style, Fourth Edition - Microsoft Press - Site Home - MSDN Blogs

RTM’d today: Microsoft Manual of Style, Fourth Edition The Microsoft Manual of Style provides essential guidance to content creators, journalists, technical writers, editors, and everyone else who writes about computer technology. Direct from the Editorial Style Board at Microsoft—you get a comprehensive glossary of both general technology terms and those specific to Microsoft; clear, concise usage and style guidelines with helpful examples and alternatives; guidance on grammar, tone, and voice; and best practices for writing content for the web, optimizing for accessibility, and communicating to a worldwide audience. Fully updated and optimized for ease of use, the Microsoft Manual of Style is designed to help you communicate clearly, consistently, and accurately about technical topics—across a range of audiences and media. This book will be available for purchase soon. For now, here is a list of the contents as well as an excerpt from the book’s Introduction.

12/06/2011

Entity Framework Batch Update and Future Queries

Entity Framework Extended Library

Pasted from <http://weblogs.asp.net/pwelter34/archive/2011/11/29/entity-framework-batch-update-and-future-queries.aspx>

 
 

A library the extends the functionality of Entity Framework.

Features

  • Batch Update and Delete
  • Future Queries
  • Audit Log

Project Package and Source

NuGet Package:

PM> Install-Package EntityFramework.Extended

Batch Update and Delete

A current limitations of the Entity Framework is that in order to update or delete an entity you have to first retrieve it into memory. Now in most scenarios this is just fine. There are however some senerios where performance would suffer. Also, for single deletes, the object must be retrieved before it can be deleted requiring two calls to the database. Batch update and delete eliminates the need to retrieve and load an entity before modifying it.

Deleting

//delete all users where FirstName matches

context.Users.Delete(u => u.FirstName == "firstname");

 
 

Update

//update all tasks with status of 1 to status of 2

context.Tasks.Update(

t => t.StatusId == 1,

t => new Task {StatusId = 2});

 
 

//example of using an IQueryable as the filter for the update

var users = context.Users

.Where(u => u.FirstName == "firstname");

 
 

context.Users.Update(

users,

u => new User {FirstName = "newfirstname"});

 
 

Future Queries

Build up a list of queries for the data that you need and the first time any of the results are accessed, all the data will retrieved in one round trip to the database server. Reducing the number of trips to the database is a great. Using this feature is as simple as appending .Future() to the end of your queries. To use the Future Queries, make sure to import the EntityFramework.Extensions namespace.

Future queries are created with the following extension methods...

  • Future()
  • FutureFirstOrDefault()
  • FutureCount()

Sample

// build up queries

var q1 = db.Users

.Where(t => t.EmailAddress == "one@test.com")

.Future();

 
 

var q2 = db.Tasks

.Where(t => t.Summary == "Test")

.Future();

 
 

// this triggers the loading of all the future queries

var users = q1.ToList();

In the example above, there are 2 queries built up, as soon as one of the queries is enumerated, it triggers the batch load of both queries.

// base query

var q = db.Tasks.Where(t => t.Priority == 2);

// get total count

var q1 = q.FutureCount();

// get page

var q2 = q.Skip(pageIndex).Take(pageSize).Future();

 
 

// triggers execute as a batch

int total = q1.Value;

var tasks = q2.ToList();

In this example, we have a common senerio where you want to page a list of tasks. In order for the GUI to setup the paging control, you need a total count. With Future, we can batch together the queries to get all the data in one database call.

Future queries work by creating the appropriate IFutureQuery object that keeps the IQuerable. The IFutureQuery object is then stored in IFutureContext.FutureQueries list. Then, when one of the IFutureQuery objects is enumerated, it calls back to IFutureContext.ExecuteFutureQueries() via the LoadAction delegate. ExecuteFutureQueries builds a batch query from all the stored IFutureQuery objects. Finally, all the IFutureQuery objects are updated with the results from the query.

Audit Log

The Audit Log feature will capture the changes to entities anytime they are submitted to the database. The Audit Log captures only the entities that are changed and only the properties on those entities that were changed. The before and after values are recorded. AuditLogger.LastAudit is where this information is held and there is a ToXml() method that makes it easy to turn the AuditLog into xml for easy storage.

The AuditLog can be customized via attributes on the entities or via a Fluent Configuration API.

Fluent Configuration

// config audit when your application is starting up...

var auditConfiguration = AuditConfiguration.Default;

 
 

auditConfiguration.IncludeRelationships = true;

auditConfiguration.LoadRelationships = true;

auditConfiguration.DefaultAuditable = true;

 
 

// customize the audit for Task entity

auditConfiguration.IsAuditable<Task>()

.NotAudited(t => t.TaskExtended)

.FormatWith(t => t.Status, v => FormatStatus(v));

 
 

// set the display member when status is a foreign key

auditConfiguration.IsAuditable<Status>()

.DisplayMember(t => t.Name);

Create an Audit Log

var db = new TrackerContext();

var audit = db.BeginAudit();

 
 

// make some updates ...

 
 

db.SaveChanges();

var log = audit.LastLog;

 
 

Published Tuesday, November 29, 2011 10:24 AM by pwelter34

Filed under: .net, Entity Framework