Orcas Beta1 Success Story

Wow — it is great to be done with Orcas Beta1… I can’t wait to see what the feedback is like…

As it would happen, today I had an “Orcas success story”…  

Steve Marx is helping me with a demo for Mix and we just today moved it over from VS2005+ASP.NET AJAX+Silverlight to Orcas+Silverlight.   In doing so Steve “touched up” a few of the lines of code I wrote to take advantage of Orcas. Here is one such example…. I needed to enumerate all the items in a database, in each row I open an xml file that is referenced from the database and then pull some data out of that file and finally return that data in IEnumerable…

The code I wrote:


public class VideoDatabaseSiteMapData : DynamicDataSearchSiteMapProvider


    public override IEnumerable DataQuery()


        SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings[“ConnectionString”].ConnectionString);


        SqlCommand objCmd = new SqlCommand(“SELECT * FROM [Items] ORDER BY [Title]”, objConn);

        SqlDataReader reader = objCmd.ExecuteReader();


        List<VideoDataBaseEntry> list = new List<VideoDataBaseEntry>();


        while (reader.Read())


            string mediaDefinitionPath = reader[“mediaDefinitionPath”].ToString();


            foreach (string s in this.GetTimeStamps(mediaDefinitionPath))


                VideoDataBaseEntry v = new VideoDataBaseEntry();

                v.ID = reader[“ID”].ToString();

                v.Timestamp = s;







        return list.ToArray();



    public IEnumerable<string> GetTimeStamps(string path)


        List<string> l = new List<string>();


        foreach (string line in File.ReadAllLines(HttpContext.Current.Server.MapPath(path)))


            if (line.Contains(“<timeIndex>”))


                int i = line.IndexOf(“<timeIndex>”) + “<timeIndex>”.Length;

                int j = line.IndexOf(“</timeIndex>”);

                l.Add(line.Substring(i + 1, j-i-1));



        return l;




which he changed to:

public class VideoDatabaseSiteMapData : DynamicDataSearchSiteMapProvider


    public override IEnumerable DataQuery()


        return from video in new VideoDatabaseDataContext().Items.ToList()

               where video.MediaDefinitionPath != “”

               from node in XDocument.Load(HttpContext.Current.Server.MapPath(video.MediaDefinitionPath))


               select new VideoDataBaseEntry { ID = video.ID, Timestamp = node.Value };




Pretty good huh?   I am glad I have Steve helping with this demo!   BTW, Come to my talk at Mix, or watch my blog here for more details on what the demo does… but it sounds cool doesn’t it??

How about you?  got any Orcas Success Stories??


Comments (11)

  1. I’m working on two projects in the evenings: One is an XNA app (no surprises there), and the other is

  2. Jason says:

    I don’t know if I would necessarily call this a success story.  Less code is definitely nice… but I think that readability suffers with all of that on one line.

    And, I imagine that debugging this would be nearly impossible.

  3. Joku says:

    I have to agree – even after we become more familiar with the new constructs and syntax, there needs to be a "solid story" for when things go wrong. I haven’t had time to try Orcas Beta 1 yet but back in LINQ May ctp some of the errors reminded me of C++ template/macro errors, very very long unreadable lines and little possibility to dive into step by step of what’s happening behind the scenes.

    There has to be good story for figuring out what exactly is going on so it doesn’t turn out like perl obfuscation.

  4. Joku says:

    (the above demo is still pretty readable but it’s really easy to go overboard and already seen some do this)

  5. - says:

    Success story?

    That in-line SQL and string manipulation of an XML file could easily be refactored to the same amount of lines by using VS 2005/.NET 2.0 in combination with good coding practices.  Or even proper understanding of things like XPath.

    I would be more interesting in seeing an example where Orcas/LINQ provided benefit, not just when "Steve" was able to refactor poorly written code.

  6. Steve says:

    So, what is new about it?

    I haven’t seen a list of what is different anywhere yet.

  7. KNOCKS says:

    Isn’t good debugging the primary skill of a good developer?

  8. zahira says:

    that good !!!really i hope to have some mails with some exemples of applications or demo to lern more cause  i gegan to forgete some thing called programming!!!

  9. Mike says:

    I can’t believe you named your connection object objConn. That’s sooo 90’s 😉

  10. Willy-Peter Schaub on Redmond Sabbatical – Day 5. Brad Abrams on Orcas Beta1 Success Story The Microsoft…

  11. WOOHOO!!! .NET Framework 3.5 Beta1 has been released. Other related blogs: JasonZ’s blog: http://blogs.msdn.com/jasonz/archive/2007/04/27/net-framework-3-5-beta-1-redist-released.aspx