All posts by Julie

Creating and consuming a WCF service to test the EntityBag class

Danny Simmons has posted the code for his EntityBag class (aka “Perseus”) on the MSDN Code Gallery Site here.

I grabbed it last night and set up a test project so that I could see what the payload looks like.

The results of that test are in this blog post, Testing out the EntityBag.

There were a few tricks for getting the web service to work properly if you are not familiar with using WCF, so I wanted to show that code.

I started by creating a DLL library just to host my EDM.

Then I created a WCF Service. The WCF service references the EDM project and the Perseus project.

I created my interface along with a HelloWorld op which is always handy for testing.

<OperationContract()> _
   <ServiceKnownType(GetType(SalesOrderHeader))> _
   <ServiceKnownType(GetType(SalesOrderDetail))> _
 Function GetData(ByVal value As Integer) As Perseus.EntityBag(Of SalesOrderHeader)

 <OperationContract()> _
 Function HelloWorld() As String

There’s something critical in the above example. Without the ServiceKnownType declarations for the SalesOrderHeader and SalesOrderDetail, you will get an error when the service tries to serialize the return data. You can read more about this here. In C#, you use typeof() where I have GetType().

Then I created the methods that implement these interfaces in my Service class.

 Public Function GetData(ByVal value As Integer) As Perseus.EntityBag(Of SalesOrderHeader) _
  Implements IService1.GetData
    Using aw As New awEntities
      Dim order = (From ord In aw.SalesOrderHeaders.Include(“SalesOrderDetails”) _
                  Where ord.SalesOrderID = value _
                  Select ord).First
      Return aw.CreateEntityBag(Of SalesOrderHeader)(order) 
    End Using 
  End Function

  Public Function HelloWorld() As String Implements IService1.HelloWorld
    Return “Hello World”
  End Function

Next is the ConsoleApp that will call the service.

Nothing fancy here, I make a service reference to the service in the project and a references to the Perseus project and the project that hosts my EDM. In code, I instantiate the service, then call HelloWorld to make sure things are wired up properly and finally the GetData method passing in an  OrderNumber. Not sure why I didn’t use orderid. Just too focused on other things at the time!

   Dim ordEntityBag As Perseus.EntityBag(Of SalesOrderHeader)
   Dim svc = New ServiceReference1.Service1Client
   Dim s = svc.HelloWorld
   Try
     ordEntityBag = svc.GetData(71780)
   Catch timeout As TimeoutException
     svc.Abort()
   Catch commException As System.ServiceModel.CommunicationException
     svc.Abort()
   End Try

This returns an unmodified object. Next I wanted to see what it looked like if it was modified so I just added some code into the GetData method in the service.

Public Function GetData(ByVal value As Integer) As Perseus.EntityBag(Of SalesOrderHeader) Implements IService1.GetData
  Using aw As New awEntities
    Dim order = (From ord In aw.SalesOrderHeaders.Include(“SalesOrderDetails”) _
                Where ord.SalesOrderID = value _
                Select ord).First
    order.Comment = “12345”
    Dim i As Int32
    For Each sd As SalesOrderDetail In order.SalesOrderDetails
      sd.OrderQty = 25
      If i = 10 Or i = 12 Then
        sd.OrderQty = 0
      End If
      i += 1
    Next
    Dim sod = From s In order.SalesOrderDetails Where s.OrderQty = 0 Select s
    For i = sod.Count To 1 Step -1
      aw.DeleteObject(sod(i – 1))
    Next 
    Return aw.CreateEntityBag(Of SalesOrderHeader)(order)

  End Using

End Function

Here’s what the EntityBag for this looks like when it gets back to the client:

Entity Framework Toolkits and Extensions collection on MSDN Code Gallery

Zlatko wrote the eSQLBlast tool.

Danny‘s been writing Extension Methods and the ENtityBag class.

There is also a new tool for examining how code generation is done from an EDMX file. (As well as a blog by Sanjay about how code gen is done.)

All of these and future stuff are now collected under one umbrella, the Entity Framework Toolkits and Extensions page on the new MSDN Code Sharing site.

It also has an RSS feed, so you can see what gets added in the future.

Thanks Diego for pointing it out.

After three years, I discover how to choose a ClickOnce Icon in MageUI

This is completely insane. Someone from Romania emailed me about selecting an icon file for a ClickOnce deployment so that the application icon is used for the installation and for the shortcut.

He had tried my hack that I have blogged about, written about in CoDe Magazine and shown in conference presentations. The hack requires manual editing of the manifest file and I learned it in the forums.

I had never been able to discover any other way to do it.

There is a new version of the MAGEUI tool, the UI for building ClickOnce manifests, so I went in to see if there was anything different with respect to that.

On the file page, things looked the same as always:

So I was staring at it and looking at the file type column and wishing I could use it. But it’s always appeared to be disabled. While I was staring and thinking, I was clicking on that and on the second click, a drop down list appeared.

And when I clicked the arrow, there it was!

Understand, that in a normal UI property sheet like this, the arrow would be visible when you first click the cell.

So I went back to the previous version of MAGEUI and after two clicks, no dropdown. But guess what, one more click and there it was!

All this time? All of the blog posts I wrote, the article in CoDe Magazine. Nobody every emailed me to tell me “oh, here’s how”. You’d think…  Clearly it’s not THAT obvious! Oh well.

I haven’t ever seen this documented (though I sure wish there was a copy of Brian Noyes ClickOnce book nearby to see if he knew).

Well, there you have it.

Testing out the EntityBag

I’ve been fiddling with the EntityBag that Danny Simmons wrote. My biggest interest was in how big the payload is.

I created a service that had two operations. The first returns “Hello World” and the second returns an EntityBag for an AdventureWorksLT SalesOrderHeader graph that includes it’s SalesOrderDetails.

Then I created a console app to call the two operations, passing in a sales order number for the second. The particular order I chose had 14 sales order details.

When digging into the message trace, here is the payload of the Hello World (it’s encrypted (symmetric) – so slightly larger than the actual 11 letters :-)) and the payload from the EntityBag when the entity is unmodified.

Next I edited the order. I modified one value in the order and one value in each detail. I deleted two details from the order.

Here’s what the EntityBag looks like after this:

Yet the payload is not very much different in size than before

It’s good to see the size of this as stake in the ground. It’s only one entity graph. Now you can see why serializing an objectcontext can be very expensive! The whole concept is still very interesting. I can see using this thing carefully, for example only sending entitybags for modified entities and not wasting the bandwidth to send a whole entitybag that just says “nothing’s changed”.

I’ll dig further (thanks for the great entertainment Danny) and tomorrow I’ll show how I built the service. There are a few WCF tricks you need to be aware of.

I haven’t fiddled with WCF in a while and it was fun digging in again and poking around in the messages.

Speaking of Ent. Framework providers – what about Access/OleDB?

My last post was about LINQ and EF Data Providers, which made me think of this.

I received an email recently asking if I knew of anyone writing an Entity Framework provider for Access.

I don’t happen to know of any.

However there’s a reason.

In the forums, there is a post from July where Danny Simmons explained the hurdles with a possible Access provider:

The OLE-DB ado.net provider has not been extended to support the entity framework, and we do not currently have plans to do so in our first release.  Further, this would be a fairly difficult effort because OLE-DB doesn’t provide enough information in general to translate CQTs (canonical query trees–the entity framework intermediate query representation) to a particular back-end query syntax.  So, while it would be possible to write an Access provider which would translate from CQTs to the particular query syntax that access uses, we don’t have an access-specific ado.net provider, and the general OLE-DB provider would not be able to do the job.

We have done some internal prototyping of how Access and the entity framework might work great together in the long-run, but those were just explorations, and we will not have direct support for Access in the first release of the entity framework.

 

Should database providers be targeting LINQ or Entity Framework?

People are always asking “when will I be able to use LINQ against databaseA or databaseB?” and “when will I be able to use Entity Framework against databaseA or databaseB?”

In my mind this is the same question, though most who are asking don’t realize it. Why?

An Entity Framework provider gets all of the benefits of the Entity Framework and also gets LINQ for free by way of LINQ to Entities.

If a database vendor wants developers to be able to perform LINQ queries against their database, it’s not a stretch to think that they might also want developers to be able to use their database within the Entity Framework.

Why write two providers (a LINQ provider AND an EF provider) when they can write just an EF provider and with it, get LINQ capabilities as well?

An added benefit is that with Entity SQL, it is possible to add provider specific functions.  So when a developer reaches a wall trying to write a LINQ query, the can just step back and use Entity SQL for those cases.

I’m definitely using LINQ to SQL where it makes sense for me. In fact, I’m waiting for a sysadmin to throw .NET 3.5 on my client’s web server so I can deploy my first production solution that uses LINQ to SQL! 🙂

But for any other db’s, I’m not waiting to see who is writing LINQ providers for their databases, but who is writing EF providers (here’s a current list, by the way).

Seven Days focus issue on High Tech in Vermont (and Career Jam)

This weeks Seven Days features Vermont’s Tech businesses and the Vermont 3.0 Tech/Creative Career Jam that is happening on Saturday (Jan 26) in Burlington. There are 50 companies that are registered as exhibitors for the career portion of this – most of them are looking for some type of technical workers – engineers, programmers and more. There was only space for 50 and there’s a long list of companies that are begging to get in as well.

The issue talks to a number of these companies and also surveys the state of the industry and career opportunities.

So if you aren’t local and can’t pick up Seven Days in print, you can read all of these articles in the paper.

Seven Days home

Seven Days TechBiz Issue starting point

  • VT Tech Biz Issue: Is Vermont’s “brain drain” reality or rhetoric : Title speaks for itself
  • VT Tech Biz Issue: Sensor and Sensibility : Microstrain – Very successful tech company in Vermont
  • VT Tech Biz Issue: They’ve Got Game : Champlain College’s Innovative Video Game course
  • VT Tech Biz Issue: Soft…where? : A closer look at five of Vermont’s software companies
  • VT Tech Biz Issue: Good to the Last Byte : Even the food writer gets in on the trend
  • VT Tech Biz Issue: Clicks to Licks : Guitar Hero!
  • VIDEO: The Campus Question: St. Michael’s College
  • VIDEO: Stuck in Vermont: Dealer.com : Video Blogger Eva Solberger visits one of Vermont’s hippest, fastest growing software companies
  •  

    Vermont IT Jobs: Web Developer in White River Junction, VT

    (note that RSG is also currently looking for a web developer with less experience required than the position below)

    RESOURCE SYSTEMS GROUP is a multi-disciplinary, employee-owned consulting firm specializing in the planning, analysis, and management of business, infrastructure and natural resources. We serve clients who share our belief that high-quality, objective analysis is a prerequisite to resolving complex problems. More than just analysts, scientists, and engineers, we’re communicators – our study results are clear, concise, and directly applicable to a client’s particular questions and challenges. Our solutions are creative and grounded by 20 years of experience with clients as large as federal government agencies and Fortune 500 companies or as small as neighborhood interest groups and local municipalities.

    Senior Associate – Software Development
    White River Junction, VT or Chicago, IL

    This position involves working with the Technology Solutions Practice, supporting the firm’s software and analysis needs. The primary focus will be developing fully dynamic web-based solutions from interface to business logic to back end database design. Managing clients’ expectations throughout the project lifecycle is a key responsibility.  We are looking for someone who is organized, analytical, and experienced in delivering best practice solutions to join our team.

    • Minimum bachelor’s degree with emphasis in computer science or a related field
    • Minimum 3 years experience working on large client projects.
    • Demonstrated software development, programming, design and technical presentation skills.
    • Outstanding written and oral communication skills.
    • Practical experience in the following areas:
    o Web Development in HTML and CSS
    o Database programming in SQL
    o Modern object-oriented programming (e.g. C#, VB.Net, Java)

    This position may be located either at White River Junction, Vermont or Chicago, Illinois.   Telecommuting from another location will be considered for the right candidate.
    Please send resume and cover letter to Recruiting Director at employment@rsginc.com and indicate Senior Associate Software Development in the subject heading.
    Recognized as one of the “Best Places to Work in Vermont” and recipient of the 2007 Dean C. Davis Outstanding Business Award, RSG employees enjoy excellent benefits, flexible hours and opportunities for advancement.
    We are an equal-opportunity/affirmative action employer.
    Please visit www.rsginc.com for more information on Resource Systems Group.

    New Burlington PHP User Group! Next meeting is Wed, January 30th

    Burlington, VT PHP Users Group Meeting

    RSVP Required

    When: Wednesday January 30th, 2008, 5:30 pm – 7:30 pm
    Where: Brown & Jenkins Coffee Roasters, 91 Ethan Allen Drive, South Burlington, VT 05403

    Topics 

    Bradley Holt will be giving a presentation on developing a web application using Zend Framework. Bradley Holt is founder and web developer for Found Line, a local design and development studio which has used Zend Framework in several recent projects. He also works as a software developer for a local non-profit. Before starting Found Line he worked as computer trainer teaching a variety of subjects including Java/JSP, ASP.NET, and PHP.

    Other topics will include:

    • What tools do you use for your development environment?
    • What subjects and presenters would you like to see in future?

    Refreshments – coffee and snacks – will be provided, and you’ll have the chance to network and connect with fellow PHP developers.

    To Participate

    1. RSVP by email to Rob Riggen <rob@riggen.org>.
    2. Sign up for the Burlington, VT PHP User Group list on Google Groups.
    3. Forward this link to anyone else you feel would be interested in the topics above.