Tuesday, March 06, 2007

I just took a peek at the list of abstracts on the Code Camp 7 site, with a thought to decreasing mine from three to two. However, there aren't tons in there yet. There could SO easily be more. Do a chalk talk. Come show off someting you've been working on or something you think is really cool. There is no need for a TechEd type of presentation. If you've got a story to tell, surely there are plenty of geeks who will be interested in hearing about it!

http://thedevcommunity.org/

Tuesday, March 06, 2007 2:01:28 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

There are SO many ways to "skin the data access cat" in Orcas that I'm getting a little cross-eyed. (Though this could be from looking at all of the XML in the Entity Data Models.)

I thought I would try to sort it out a little here since I have done this for some of the presentations I am putting together.

ADO.NET in Visual Studio Orcas

The "new" ADO.NET is not new, but added to. Evolution and backwards compatibility are key to the ADO.NET team. So in Orcas you will have what you know as ADO.NET 2.0 basically in tact. Then added onto that are two things: Entity Framework and integration with LINQ.

LINQ Integration in ADO.NET (in VS Orcas).

Painting a broad brush stroke to define LINQ is that it gives you the ability to query in-memory objects (that are iEnumerable).

 While there is the basic LINQ to Objects syntax, there are four derivatives of this.

LINQ to XML allows you to use LINQ to query XML.

There are three others that all fall under the umbrella of LINQ to ADO.NET.

The first of these is LINQ to DataSet. DataSets are in-memory objects, right? So we can query them, too. What we are really querying is an Enumerable collection of DataRows. Because of the special nature of DataSets, this "flavor" of LINQ needs to be specialized.

Next is LINQ to SQL. Of course, this taints my brushstroke because SQL is not an in-memory object. :-) However, as long as we have this fabulous new language enhancement, and we are all over querying databases, this version of LINQ was created to work directly with SQL, not only to query, but to update the data as well.

The last of the LINQs is LINQ to Entities. This lets us use LINQ to query the objects that are created by the Entity Framework. So let me jump to that and then come back to this one.

Entity Framework

Entity Framework is a whole new set of APIs added into the System.Data namespace.

The key to the framework is a set of three schema files.

The first file describes the conceptual layer of your business entities using a schema file. This is not replacing your objects. All we are describing is structure and basic metadata. Two of the (many) big advantages of this are that 1) in the end, we can write our data access code against this schema (which creates classes for us) rather than having to code up connections to the db, create complex joins to pull together info from various related tables and write lots of update logic and 2) we can describe these conceptual entities based on what we want them to look like, rather than how they are best organized in a database.

The second files describes the schema of the database, including pk/fk relationships.

The third file is a map between the first two. So that when you code against the entities, the framework can translate your requests (or updates) into what the database is expecting.

So those are just three files (which can be created directly from your db using a wizard or a command line tool and then edited manually).

Interacting with the schema files

There are two APIs that know how to make these schemas do their magic, Object Services and Entity Client.

Object Services

Object Services know how to work with the entities as objects. You can query against the entities and get objects as your results. These objects are managed in memory by Object Services and you can update the database easily with changes made to the objects. So I said the magic word, query.

There are two ways to query with the object services. 1) Directly using (yet ANOTHER query syntax...) Entity SQL, which is similar to using SQL and is built using strings. Here you would use the ObjectServices API to create a query object and then pass in the Entity SQL string 2) Indirectly using LINQ to Entities. If you use LINQ to Entities to query the entity classes, in the background LINQ to Entities will use Object Services to interact with the objects. Either way, ObjectServices will maintain in-memory knowledge of the objects for updates.

There are  providers being built to interact with other databases. Regardless of the database, once the schemas and mapping are built, everytihng you do on the client side will be the same.

A caveat is that if you use Object Services plus Entity SQL to query and in your query you use projections (request specific columns/properties instead of entire objects) you will not get an updatable object. Instead you will get an IEnumerable collection of DbDataRecords. LINQ to Entities will return objects even with projections, because that's what LINQ knows how to do.

Entity Client

The last thing I wanted to talk about is Entity Client, the other way to access entities. EntityClient is a provider, similar to SQLClient and the others. It let's you build your data access code to query the entities in a familiar way, with connections (though the connection points to your entity objects) and commands. With EntityClient, you build queries using Entity SQL syntax. EntityClient queries return a dbDataReader. You cannot do updates directly through EntityClient. An interesting thing about this provider is that if you are building an app that leverages the Provider Independent API, you can have code that easily flips back and forth from access data in SQL Server, Oracle, Access, or other data engines. So (though I haven't tested this, I'm making an educated guess here) you can add EntityClient into this flexible model.

Summary

So now you can see why I'm a little cross-eyed. We are working with 6 new query languages (though they are all related),5 new ways of accessing data, trying to keep track of which syntax goes with which access method and which access method returns what type of data. And it is dizzying for sure. But after some investment in this, I have definitely gotten it sorted out. And you can too!

 

Tuesday, March 06, 2007 12:05:33 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
 Monday, March 05, 2007

I wrote up a list of some of the invaluable resources I have been relying on while diving deeply into the new March CTP of Orcas.

[A DevLife post]

Monday, March 05, 2007 9:08:56 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

In a previous interation, I managed to track down some sample code that built a LINQ call to a stored procedure, the class which it returns and executed it in LINQ to SQL.

The code has changed dramatically in the March CTP. Luckily, Mike Taulty beat me to it and I leveraged the C# code in his post to revise mine.

One of the things I was so silly to do in my previous test was to hand code the return class rather than just create it in the designer and return that.

But all of this is not totally necessary since you can now drag and drop stored procs onto the LINQ to SQL Visual Modeler and make calls to it. Interestingly the return type is just created on the fly at run time so it's not even an issue - yay to anonymous types.

However, it's still nice to know how to build this stuff becasue drag n drop doesn't solve every coding problem. So check Mike's post for the C# version.

Here is a working version in VB.

"CustOrderHist" is the name of the stored procedure in my database. 

What this is doing is

1) using the attribute to hook it up to the sproc
2) taking in a parameter of customerID and associating it with the parameter @CustomerID in the stored proceudre
3) Returning and IEnumerable of type CustOrderHistoryResult (the class I created in the designer that matches the structure of what the sproc returns).

On the client side, I can now take the result and do whatever I want with it, such as bind it to a gridview on a web page.

<StoredProcedure(Name:="CustOrderHist")> _
Public Function GetCustOrderHist(<Parameter(Name:="CustomerID")> ByVal customerID As String) As IEnumerable(Of CustOrderHistoryResult)

  Dim result As IQueryResults(Of CustOrderHistoryResult) = _
 
ExecuteMethodCall(Of CustOrderHistoryResult)(Me,
  MethodInfo.GetCurrentMethod, customerID)
    
  Return result

  End Function

Monday, March 05, 2007 4:52:17 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Oh, and the cat, too.

I've been working from th ekitchen for about a week so I can hang out with the dogs. They don't do stairs anymore and we haven't cleared the path through the snow for them to get to my office from the outside.

So here they are hanging out withme. G.B. the cat has found his favorite warm spot in the house (with Tasha) and Daisy is on her cushy bed. What a mush.

Monday, March 05, 2007 2:41:08 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
 Sunday, March 04, 2007

Thanks again to Kate (she sure helps funnel good info for me), I see that Microsoft is sponsoring a contest to win a full paid trip to this [Microsoft sponsored?] summit.

You need to be a software developer chick (sorry guys), live in one of these 5 countries: Austria, Denmark, France, Germany or the UK, and not work for Microsoft.

The submission is an essay and due by April 2.

Check it out here.

Sunday, March 04, 2007 8:55:37 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, March 02, 2007

The stars have aligned and I'm going to MIX07.

I am ignoring the fact that this is going to mean a whole lot of flying . In a 5 week period I will fly to Orlando and back (from Vermont), then to Seattle and back and then to Las Vegas and back. Oy, silly me.

 

Friday, March 02, 2007 5:03:20 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 

VB9 has come a long way in the new March CTP of Orcas! Paul Vick has a quick list of what is now in there. And there are a lot of good details in the msdn documentaiton that comes along with the CTP.

A few things I noticed quickly when bringing my LINQ for SQL demos over to the new bits.

  • First, and happily, the named parameter syntax of := is no longer necessary. You can just type =, like a normal person.
  • You need to be explicit about using the reference to the entity when refering to properties. In other words where I could say
     From s In db.Suppliers_
                Where CompanyName = "Exotic Liquids" ...
    I now need to put  "s." in front of the CompanyName property
  • The anonymous types have been fleshed out more and you need to use the With keyword when creating one.
  • Also in the anonymous types, when you are definining a new named parameter, you need the "." in front of that parameter, so it is obviously a property of the anonymous type.
  • Maybe this isn't the ultimate way to do it, but it seems that if you want to further leverage one of the properties of that anonymous type, eg to order on, then you need to name the anonymous type and reference it in the order by clause. Again, maybe this isn't THE way, but it's the way I got my code working again.

Here's a before (as in earlier CTP) and an after (March CTP) example of a simple query that does all of these things.

OLD
From s In db.Suppliers _
            Select New {Company := CompanyName, Country, Products}

NEW
From s In db.Suppliers _
            Select New With {.Company = s.CompanyName, s.Country, s.Products}

Here's what it looks like with a nested query
  From s In db.Suppliers _
            Select New With {.Company = s.CompanyName, s.Country, _
            .Products = (From p In s.Products _
                Select New With {p.ProductName})}

OLD with Order By
From s In db.Suppliers _
            Select New {s.CompanyName, s.Country, s.Products} _
            Order By CompanyName

NEW with Order By
  Dim mylist = From s In db.Suppliers _
            Select s2 = New With {s.CompanyName, s.Country, s.Products} _
            Order By s2.CompanyName

I've seen samples where "s" has been used for both the reference to the items in the db.suppliers collection AND to the name of the new anonymous type. That scares me, so I used a new variable (s2).

There is also a whole new set of query samples in the MSDN documentation.

Friday, March 02, 2007 2:38:37 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [5]  | 

Yesterday I proclaimed that today would be a powder day - regardless of how much work I have to do. We had a forecast of 7-12 inches of new snow.

The promised snow started before we went to bed last night.

But when I woke up in the middle of the night to a howling wind and then again this morning to the same, I knew it would be another productive day in front of the computer. It's wild out there. Rich is still heading out to the ski hill. He's insane. I certainly wouldn't want to be sitting in the chair lift in this weather.

It's what he refers to as a "character building day." That's an old joke from when he worked for a builder that, even in the winter, had his crew arrive at 6am and work until 4pm. Even when it was 5 degrees out and all then ended up doing was shoveling snow out of the foundation. I'd last about five minutes in a job like that. Give me my cozy office chair any day! :-)

Friday, March 02, 2007 8:21:06 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [3]  | 
 Thursday, March 01, 2007

Expecting some new snow overnight and tomorrow.  Yay. We will go do some runs in the morning. I'm currently averaging about $50/run based on the cost of my midweek pass and the number of runs I've managed to get in this year.

Thursday, March 01, 2007 10:47:50 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

The ADO NET Team has been cranking out fab content on their blog. Brian Dawson just wrote a post all about Object Services.

In trying to sort out all of the options that we now have with Entity Framework and LINQ, I'm always happy to see a list like this. But go read the whole post so nothing is out of context

What can you do with Object Services?

Here’s a bullet list of some of the normal operations which object services can provide:

·         Query using LINQ or Entity SQL

·         CRUD

·         State Management – change tracking with events

·         Lazy loading

·         Inheritance

·         Navigating relationships

More features of Object Services allow for data conflicts resolution. For example, Object Services supports:

·         Optimistic concurrency

·         Identity resolution -  keeping on copy of the object even from several different queries

·         Merging

·         Refreshing data with overwrite options (ie: server wins or client wins)

Thursday, March 01, 2007 10:01:53 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

I will be speaking in Albany NY at TechValley.NET on March 12th about ADO.NET Orcas.

In April I will be doing a two city tour speaking at Bellingham.NET (a group led by Andrew Robinson, that is a brand new member of INETA) and then at South Sound .NET in Olympia, Washington run by my old INETA pal, Paul Mehner (with help from another pal, Camey Combs.)

In between these two trips, I'll be at DevConnections in Orlando and Code Camp 7 in Waltham, Mass. I guess "travel season" is starting!

I'm looking forward to all of these trips! Now back to that new CTP release.

Thursday, March 01, 2007 9:49:28 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 

After reading this in the Free Press, I had a great idea what we can do with any funds coming to Vermont - support the high tech industry here! How fitting.

Vermont shares in $90 million settlement with Samsung

Published: Wednesday, February 7, 2007
MONTPELIER - Vermont is one of 40 states to settle with electronics manufacturer Samsung in an antitrust lawsuit, Vermont Attorney General William Sorrell announced this week.

The $90 million nationwide settlement with Samsung Semiconductor, Inc. and Samsung Electronics Co., Ltd. arose from a claim of a price-fixing scheme among Samsung and several other of the world's largest computer memory chip manufacturers that began in the 1990s.

The settlement, which is still subject to a court review, does not yet detail how the money will be meted out among the suit's participating states and consumers.

Thursday, March 01, 2007 9:26:29 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Here's a recent opinion piece in the local paper about the importance of Green businesses in Vermont. I keep harping about how green the software industry is at VTSDA meetings and want to get the state to include us in all of their efforts around promoting green industry here. It's so good for Vermont. I will eventually get my message through! :-)

 

Thursday, March 01, 2007 9:22:15 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 

From the Feb 23 Legislative Report of the Lake Champlain Regional Chamber of Commerce

David Winslow, CEO and President of EpikOne, Inc. was recruited by the Chamber and GBIC to testify from a businessperson’s perspective about what business expects from our educational and workforce development systems.  David’s story of being an underachieving high school student to becoming an entrepreneur who owns a knowledge-based technology business employing 15 people fascinated both the House Commerce and Education committees.  The Committee members peppered him with questions about his experiences and what can be done to foster other entrepreneurial-minded young people. The essence of his testimony was that the education system should expose students to business during high school, encourage skills-based training and internships and better align the curriculum with the business needs and technology of today. He also spoke of the need for businesspersons to become more involved in the educational system to provide these opportunities.

Thursday, March 01, 2007 9:19:10 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

From the Burlington Free Press an interesting look at Vermont's "lopsided" economic evolution:

Vermont is the most entrepreneurial state in the country, according to the study. However, Vermont is last in creating high-wage service jobs; the service industry includes restaurant positions, financial and legal services, publishing and advertising. Connecticut, Delaware and New York lead this category.

Read the full article here

Thursday, March 01, 2007 9:14:17 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

I saw mention of this new version of the command line tool in this forum post so I went looking in the MarchCTP. I modified some of the desciriptions a little to fit them onto a powerpoint slide, so this is a tad different than the real tihng

C:\WINDOWS\Microsoft.NET\Framework\v3.5.20209>edmgen /help


Microsoft (R) EdmGen version 2.0.0.0
Copyright (C) Microsoft Corporation 2006. All rights reserved.

                                           EdmGen Options
/mode:ValidateArtifacts                 Validate the ssdl, msl, and csdl files
/mode:FullGeneration                    Generate ssdl, msl, csdl, and objects from the database
/mode:FromSsdlGeneration                Generate msl, csdl, and objects from an ssdl file
/mode:EntityClassGeneration             Generate objects from a csdl file
/mode:ViewGeneration                    Generate mapping views from ssdl, msl, and csdl files
/project:<string>                       The base name to be used for all the artifact files (short form: /p)

/connectionstring:<connection string>   The connection string to the database that you would like to connect to (short form: /c)
/incsdl:<file>                          The file to read the conceptual model from
/inmsl:<file>                           The file to read the mapping from
/inssdl:<file>                          The file to read the storage model from
/outcsdl:<file>                         The file to write the generated conceptual model to
/outmsl:<file>                          The file to write the generated mapping to
/outssdl:<file>                         The file to write the generated storage model to
/outobjectlayer:<file>                  The file to write the generated object layer to
/outviews:<file>                        The file to write the pre generated view objects to
/language:Vb                            Generate code using the VB language
/language:CSharp                        Generate code using the C# language
/namespace:<string>                     The namespace name to use for the conceptual modely types
/entitycontainer:<string>               The name to use for the EntityContainer in the conceptual model
/help                                   Display the usage message (short form: /?)
/nologo                                 Suppress copyright message

 

Thursday, March 01, 2007 8:56:35 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

This  month's desktop calendar is really nice. They are done by photographer Paul Hansen of ecopixel for the Green Mountain Club.

Thursday, March 01, 2007 12:34:01 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, February 28, 2007
Wednesday, February 28, 2007 6:23:22 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, February 27, 2007

There are dreams that are common for people; the one where you are flying, the one where you suddenly realize you have no clothes on and the one where you walk into college or high school class and there is a big test and you realize you haven't been to any classes all year.

Since I've been speaking at conferences, the last one of those has shifted, not once but twice.

I have often dreamt that I walked into a room to do a conference session and realized I hadn't even prepared it!

Last night I dreamt that I gave a new talk at a user group and was about to give it again about 1/2 hour later. I thought the talk had gone really well. While I was setting up to do the 2nd iteration of the talk, I asked someone (I think it was Dave Noderer) how he thought the first talk went. "Okay," he told me, "but I think it would have been nice if you had done some demos."

Luckily something woke me up from my sleep while I was trying to figure out how I was going to solve this problem with only about 10 minutes before the session started.

I do actually have a talk that is totally codeless; it is a session that explains some basic security concepts. But in this dream, I was doing a talk on ADO.NET, so no code demos probably wasn't such a good thing.

Tuesday, February 27, 2007 8:43:51 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  |