Thursday, December 13, 2007
Thursday, December 13, 2007 11:41:12 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, December 12, 2007

When I was at ReMix Boston in early October, I remember that Stan Shultes told me that someone was doing user group presentation on Entity Framework in Florida but couldn't think of the person's name at the moment. Shortly afterwards, I had an email conversation with someone who had asked an interesting question on the ADO.NET forums and when he said he lived in Florida, I correctly put two and two together. It was Jonathan Carter who had been doing the presentations.

I met Jonathan a few weeks later at an SDR at Microsoft and, although I'm used to how young many programmers seem to me now (it's all relative ... only because I"m so friggin' old now ;-)), I was surprised how young he was, but oh so smart. And of course, we had our passion for Entity Framework and Astoria in common!

This didn't go unnoticed and now Jonathan is wearing a blue badge! He is now the technical evangelist for Visual Studio and .NET Framework - a pretty impressive position to start with.

You can read more about Jonathan's new job here and then check out the rest of his blog because he's been blogging up a storm.

 

Wednesday, December 12, 2007 6:28:01 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

I've been using the GetObjectStateEntry method for a while so that I can view and interact with the state of a particular entity that I have in hand.

Today I used the plural version of this method for the first time and boy do I like it!

GetObjectStateEntries takes as a parameter an EntityState enum: Added, Modified, Deleted, Unchanged or Detached.

It provides a perfect opportunity to do some work on entities prior to hitting the datastore during a save changes event.

For example, if you have an entity with a property to track the modification date you could update that property any time any other property in the entity is changed which might be wasteful. But with the GetObjectStateEntries method, I am able to just update the Modified Date property on all changed objects at once just before I save changes.

Here's some code for dealing with the Customer entity that is derived directly from the customer table in the AdventureWorks database.

Now, this poses an architectural question and you may want to put this particular business logic elsewhere, but it's merely a demonstration of what you can do with this method.

Because the generated classes are partial classes, I just create another partial class for my AdventureWorksLTEntities class and intercept the SaveChanges method. Then I grab all of the modified objects, use the Entity property to filter just Customers, then changed the Modified Date property. Next I grab the Added objects, change the Modified Date and also add in a default password hash and password salt. These are required for customer rows. (Read more about hashing passwords here on Beth Massi's blog.)

Namespace AdventureWorksLTModel
 
  Partial Public Class AdventureWorksLTEntities

    Private Sub AdventureWorksLTEntities_SavingChanges(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SavingChanges
      Dim changedEntities = Me.ObjectStateManager.GetObjectStateEntries(EntityState.Modified)
      For Each stateEntryEntity In changedEntities
        If TypeOf stateEntryEntity.Entity Is Customer Then
          Dim cust As Customer = stateEntryEntity.Entity
          cust.ModifiedDate = Now
        End If
      Next
      Dim addedEntities = Me.ObjectStateManager.GetObjectStateEntries(EntityState.Added)
      For Each stateEntryEntity In addedEntities
        If stateEntryEntity.Entity.GetType() Is Customer Then
          Dim cust As Customer = stateEntryEntity.Entity
          cust.ModifiedDate = Now
          'password hash cannot be null
          'for demo purposes just put a default string in there
          Dim strPassword As String = "p@ssw0rd"
          Dim encoder As New System.Text.UTF8Encoding()
          Dim SHA1Hasher As New Security.Cryptography.SHA1CryptoServiceProvider
          Dim hashedBytes As Byte() = SHA1Hasher.ComputeHash(encoder.GetBytes(strPassword))
          cust.PasswordHash = Convert.ToBase64String(hashedBytes)
          'customer table also needs salt for hash
          Dim buffer() As Byte = New Byte(5) {}
          Dim rng As New System.Security.Cryptography.RNGCryptoServiceProvider()
          rng.GetBytes(buffer)
          cust.PasswordSalt = Convert.ToBase64String(buffer)
        End If
      Next
    End Sub

  End Class
End Namespace

I have a feeling that this existed in Beta2, but I have updated both of my boxes and don't feel like digging into a VPC just to verify.

Wednesday, December 12, 2007 5:50:08 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

One of the changes with the new CTP release of ADO.NET Data Services (formerly Astoria) is that you can create a service against any iQueryable, not just Entity Framework. This is huge.

Roger Jennings points to Guy Burstein's how-to with Astoria (I guess it's time to update my own now outdated posts) and makes the following comment:

"Like Andy Conrad, Guy uses LINQ to SQL instead of the Entity Framework as the data source. I have the feeling this substitution will become universal, at least until RDBMS vendors other than Microsoft deliver EntityClient data providers."

So this bugs me a little. Why? Because the issue is that right now, Entity Framework only works with SQL Server. But hello, what do you people think LINQ to SQL works with? It's called LINQ to SQL for a reason! ;-)

Okay, rant over, back to work...

Wednesday, December 12, 2007 4:50:48 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

I've done this demo many times in conference and user group sessions. Someone on the ADO.NET forums asked how to do it and I thought I would just do a quick tutorial with screenshots.

What this Tutorial does is demonstrate how to create and use a data source from a particular entity in the model. I'm just doing simple drag and drop and no filtering or anything here with the goal of just a quick basic walkthrough for getting started.

Start by creating a Windows Application.

Add an Entity Data Model.

Select Data from the menu and choose Add New Data Source

In the first page of the wizard, choose Object as your Data Source Type.

The next screen of the wizard will show the namespaces in the current solution. Open up the namespace for the application

then choose the entity which you want to use as a Data Source. I will pick customer.

Then you can Finish the Wizard.

Now to get easy access to the datasource, go back to the menu and choose Show Data Sources from the Data menu.

The DataSources Window will be placed in your IDE in it's default location. Mine docks with the windows on the left.

When it's not pinned it gets tucked away with the others. You can undock it and put it wherever you want.

I can now drag and drop the customer data source onto the windows form to get the automatic DataGridView and Navigation toolbar (this is normal behavior for DataSource and not specific to Entity Framework).

There are a few more steps to actually getting user interaction with this. You need to populate the Binding Source and if you want to edit, you'll need to add a little code to the save button on the toolbar.

You'll need to enable the BindingNavigatorSaveButton (just click the save icon on the navigator toolbar and change it's Enabled property to True). Additionally, you'll probably want to format the grid which you can do easily from it's SmartTag and more thoroughly through the properties window.

Here's what the code behind looks like in my form enabling me to view, add, delete, edit and save data.

Imports WindowsApplication1.AdventureWorksLTModel
Public Class Form1
  Private aw As AdventureWorksLTEntities
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    aw = New AdventureWorksLTEntities
    CustomerBindingSource.DataSource = aw.Customer.OrderBy(Function(cust) cust.CompanyName)
  End Sub

  Private Sub CustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CustomerBindingNavigatorSaveItem.Click aw.SaveChanges() End Sub End Class

Note that because the AdventureWorks Customer table has the following constraints: ModifiedDate must be a valid date value and the PasswordHash and PasswordSalt fields cannot be Null, I have extended the entity class to take care of these things when SaveChanges is called.

Wednesday, December 12, 2007 12:25:30 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [5]  | 
 Tuesday, December 11, 2007

Ann DeMarle is the director of the Emergent Media Center at Champlain College in Vermont. She has started blogging at http://emergentmediacenter.blogspot.com  and I look forward to her great insights!

I was honored to be invited by Ann to participate in a Degree Advisory Council for this program.

Tuesday, December 11, 2007 10:01:16 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Finally it's real live production bits to play with!!

In addition to finally using real bits, key to this release are the finalization of response formats (XML by way of ATOM and JSON), security, an AJAX client, querying with LINQ when you are using one of the clients. THere's a lot more.

Mike Flasko published 4 blog posts on the Astoria Team weblog yesterday:

ADO.NET Data Services ("Project Astoria") CTP is Released

Viewing Data Services Responses Using Atom Serialization in Internet Explorer

ADO.NET Data Services Dec2007 CTP - Validation and Access Control

LINQ to ADO.NET Data Services

 

Tuesday, December 11, 2007 9:35:00 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, December 10, 2007

While I was at my parent's house helping out with their THIRTY-FOUR new newfie pups, Tasha was at home hitting an amazing milestone! She turned 14 years old. This is very old for a newfie. While she isn't the athletic young girl she used to be thanks to arthritis, she is still full of it! Barking every morning to make sure everyone in the neighborhood knows "I'm still here!", eating like a champ and full of desire (though not the ability) to go down to the road and see what there is to see. I spent years keeping her from getting hit by cars. Now that she's old, I finally don't have to worry about that any more. Her eyesight and hearing seem to be fine and she gets acupuncture to help out with the arthritis since her back legs are quite stiff. It's hard to get up, get down and to walk. Not so hard that she's not willing though although she hasn't been doing stairs for a few years now. Every day I watch her so carefully to make sure that I'm not being selfish.

Here's a picture of her today. A little scruffy because it's basically impossible to give her a bath as we can't make her stand for a long time. We can't get her upstairs to our easy access shower to try to bathe her there either and now it's too cold to bathe her outdoors. But she doesn't mind and neither do we. She's 98!

A little less than four years ago, I took some pics when we were giving Tasha a bath at our local (wonderful) pet store that has a great setup. Even then she was old for a newf at 10 and standing for a long time was a little problematic. But look how cute she is!

No less amazing is Daisy who will be 13 in a few more weeks.

Monday, December 10, 2007 9:58:16 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
 Sunday, December 09, 2007

At the Mix n Mash  earlier this week, I asked Scott Guthrie what his opinion was about developers having to deal with SO many new technologies coming out from Microsoft at such a rapid pace.

His recommendation was to pick what is core to your work, or what you are really good at or really vested in and then ignore the rest.

Easier said than done.

Even if we follow ONLY his blog, we have myriad technologies in our faces. It's very hard to predict the future. I am currently "ignoring' .NET 3.0 (WPF, WCF & Workflow), MVC, AJAX Control Kit, SQL Server 2008, a huge chunk of Silverlight. Granted MVC is far out. Volta just showed up. Astoria is plowing ahead without me at the moment. Surface is astounding. And there's so much more.

It's very frustrating because this isn't Lays potato chips. The one I ignore may have been the one that will make a difference in my ability to support a future client.

What Scott is suggesting is akin to watching t.v. without a remote! :-) We'll see how it goes...

Sunday, December 09, 2007 1:07:43 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
 Saturday, December 08, 2007

We just got a call from my mom on her way home from the vet with the last of the three litters! Bumper had eleven puppies. We can't wait to see them.

You can keep an eye on things at my parent's website: Blue Heaven Kennels.

Here's a picture of the mommy, Bumper, at a dog show.

Saturday, December 08, 2007 6:06:05 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

It's feeding time again! These are Celeste's 6 puppies.

Saturday, December 08, 2007 4:47:24 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

(On going... you can catch up at www.blueheavennewfoundlands.com)

The second litter was born yesterday. I'm helping to watch over them today. Celeste has to feed them every two hours and they nurse for over 1/2 hour. In between everyone rests up and the puppies get a Snuggle Puppy to curl up with. These are more than toys as they have a heartbeat and are warm. Sometimes they are all underneath it. Here's what they are doing right now (there are 6 total but you can't see them all here). The upstairs puppies (the litter of 17 that is now two weeks old) get two Snuggle puppies!

Saturday, December 08, 2007 2:27:07 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

At the recent Mix n Mash 08, Bill Gates talked about how Microsoft creates their vision for software and computing and the acts upon that vision. Read more...

[A New DevLife Post]

Saturday, December 08, 2007 12:26:58 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Although I wasn't able to be in Vermont on Thursday for the Bob & Chris Roadshow or the VS2008 Installfest, I have gotten emails from Chris Bowen and others letting me know that it was a great success. Over 40 people showed up for the installfest, and I learned from Dave Burke's blog that they also had TWO XB0X 360's set up for folks to play with.

Larry Keyes blogged his extensive notes from the day.

Sorry to have missed it.

What I really enjoyed reading was Dave Burke's epiphany about VS2008. The sessions from Bob & Chris really made things click for him and he's ready to get in bed wiht VS2008. I was thinking about that becasue he said he's seen LINQ 4 times before, but not until Thursday did he finally get to his AHA! moment with it. I believe this may have a lot to do with the fact that it's finished, it's deployed and in hand, rather than seeing very early bits (we've had 3 LINQ talks at VTdotNET in the last 1 1/2 years).

Saturday, December 08, 2007 11:38:32 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

Sam Druker spends an hour talking in depth about Entity Framework in this new channel 9 video.

Saturday, December 08, 2007 10:49:33 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

After I left Seattle, rather than going home as I had planned I ended up going to my parent's house (where I still am) to attend a funeral after which I was whisked up to Canastota NY where my mom was camped out with two pregnant dogs (Celeste and Bumper) near her fabulous vet (Village Vet in Canastota) waiting for the right time to do c-sections and bring the pups into the world. Celeste had 6 beautiful puppies yesterday and I drove them back to Binghamton and am now helping out with her pups as well as the 2 week old litter of 17. Mom and my sister are still in Canastota with Bumper and they will be doing (they = vet, not my mom & sister) doing her c-section today with an expectation of 10 or more puppies.

In the meantime, what did I miss?

We were sent the entire transcript of our conversation with Bill Gates earlier this week. Keith Peters is posting it (in sections) on his blog.

Entity Framework Beta3 and the CTP2 of the tools were released.  (Also, here's a  list of breaking changes) I've only been waiting for this for months and I can't even look at it right now because I am responsible for precious little lives.

 

 

 

Saturday, December 08, 2007 9:58:51 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, December 05, 2007

Oh gawd - I was trying SO hard not to blink and overcompensated and have an odd look on my face. No matter how this looks, no, Jonathan Snook did NOT just pinch me!

From left to right

Jonathan Snook, me, Kelly Goto, Rob Howard, Bill Gates, Molly Holzschlag, Kip Kniskern, Jesse Warden, Keith Peters, Erik Natske.

Wednesday, December 05, 2007 2:16:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [6]  | 

I'm in Seattle and on my way home to Burlington. When I arrived at the airport, I saw that my flight was delayed but it didn't indicate for how long.

Shock of shocks ... there is snow in Chicago, so my flight through Chicago was potentially delayed. If it was delayed more than 1/2 hour, I would likely miss my connecton to get home - the last one of the night.

Normally, this would have made me unhappy. However, for the past two days, I had been trying to reroute my flight to Binghamton  or Syracuse NY so that I could attend a family funeral but it was going to cost $450 to make the change - with no option to use miles to pay for the difference. I had decided I would just fly home to Vermont, get up at 5am and drive the 5 hours to Syracuse.

But the delay ended up solving the problem for me. United was able to change my flight to go to Binghamton without any charge. This I can't complain about.

In the end, the Seattle to Chicago flight actually left on time, but I'm very happy that I'll be able to get to my parent's house tonight and we'll just work out the logistics of my getting back to Vermont later.

Wednesday, December 05, 2007 1:49:42 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

So I got back to my hotel room after the meeting and was getting a few things from my backpack and was sorely disappointed to find this:

A bottle of Maple Syrup I had brought with me from Vermont to give to Bill Gates. I had totally forgotten in the excitement of the whole day.

So, I very happily gave it to Tim Harris, from the DPE (Develper Platform Evangelism) team who had coordinated the trip and the day. He was already looking forward to the pancakes he plans to have tomorrow morning.

Wednesday, December 05, 2007 1:07:36 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
 Tuesday, December 04, 2007

Okay that was fun. I was the third one to ask a question and about one minute before my time there were suddenly about 5000 in my head.

Each person asked a question and each question started him off on an interesting road.

There will be a transcript provided so I'm not going to bother trying to share the entire conversation.

When we first sat down, I feared that my pulse was racing, but then it was easy to get absorbed in what he was talking about.

Interesting to me was his discussion of vision - that a lot of the driving force is based on the dream of what computing should be able to achieve someday.

For me, however, the most exciting thing is that with all of the money and power that Bill Gates wields, he continues to change the world through the Gates Foundation.

I managed to suggest that if he ever wanted to open a Gates Foundation office in Vermont, to give me a call...

We had a group photo that we'll get along with the transcript.

And no, we didn't get a zune - but I've got my Nano.

Tuesday, December 04, 2007 8:22:25 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  |