Your SlideShare is downloading. ×
  • Like
Daniel Egan Msdn Tech Days Oc Day2
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Daniel Egan Msdn Tech Days Oc Day2



Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Daniel N. Egan Microsoft – Developer Evangelist Building a VSTO application using LINQ
  • 2.
    • Daniel Egan –Developer Evangelist Microsoft MCSD,
    • Former Microsoft Regional Director Microsoft MVP – ASP.Net, MCSD, MCT
    • Former INETA President
    • INETA Speakers Bureau
    • Author : Building Websites with VB.Net and DotNetNuke 3.0 Packt Publishing
    • .Net Certificate Instructor California State University Fullerton
    • CSUF .Net Advisory Board Member
    • Run
    • Co-Founder – SoCalDotNet
    • TwitterID : DanielEgan
    Daniel Egan
  • 3.
    • INETA – International .Net Association
    • User groups in this Area.
    • OCDotNet –
    • SoCalDotNet –
    • South Bay .Net -
    • LADotNet –
    • LA C# -
    • SGV –
    • Inland Empire –
    User Groups
  • 4.
    • m.Twitter.Com
    • #TechDays
    Twitter Your questions…
  • 5. Session Objectives And Agenda Walk through of the fundamentals of VSTO development The LINQ how and why Demos, Demos, Demos…
  • 6.  
  • 7. Developing on Microsoft Office
  • 8. A unified solutions platform for building Office Business Applications that make line-of-business systems, enterprise data and workflows accessible and relevant to users. Premiere developer tools for developing Office Business Applications and scalable enterprise grade solutions utilizing Visual Studio and Microsoft Office
  • 9.
    • Integrated design-time experience
    • Increased security through .NET Framework
    • Document-level & application-level task pane customizations
    • Support for managed controls
    • Support for host controls
    • Ability to add controls at design-time or dynamically at run-time
    • Quick development
    • Competitive advantage
    • Strength of two major products
  • 10.  
  • 11. What About VBA?
  • 12. Scenarios Tools Post 2003 N-tier Distributed Apps Complex document add-ins (high reuse) Simple document add-ins (high reuse) Simple document add-ins (low reuse) Macro modify Macro record/replay Advanced app-level add-ins Simple app-level add-ins Application repurposing VBA (as intended) VBA (as applied) Market Gap Tools Pre 2003 Scenarios Complexity
  • 13. Reasons for Using VSTO vs. VBA * There are no pending plans to retire VBA at this time
      • Limited functionality and flexibility
      • Code in document = no source code/version control
      • Choice of Visual Basic .NET or C#
      • Pro dev environment & tools; access to .NET Framework
      • VBA has a casual security model = high potential security risk
      • VSTO solutions employ the .NET Security model
      • Take advantage of the 2007 Office system development platform
      • Utilize the full benefits of the Visual Studio development environment
  • 14. Ask These Questions What business problem does this VBA solution address? What parts of this solution, if any, can I leave in VBA? Does it make sense to move this VBA solution to VSTO?
  • 15. Call VSTO from VBA
    • Developers enable VBA via COM Interop
    • Interop implemented at design time
    • Developers can then call VSTO from VBA with IntelliSense after building the project
  • 16. VSTO and 2007 Office System
  • 17. Custom Task Panes
    • VSTO 2005 SE provides app-level custom task panes
    • Create custom task panes with an add-in
    • Add-in support & task pane support for
      • Project, Excel, InfoPath, Outlook, PowerPoint, Word
    • Custom task panes appear in the main application window or (Outlook) inspectors
    • Populate custom task pane with UserControls
      • Populate user controls with Winform controls
  • 18. Outlook Form Regions
    • Implement a custom form region with an add-in
    • Runtime and design-time support
  • 19. Outlook Form Region Wizard
    • VSTO simplifies and speeds up Outlook form region design and configuration process with a visual designer
      • Achieve maximum form region design flexibility with VS visual designer
      • Configure your form region with a simple, intuitive wizard
      • Run and debug your form region right from Visual Studio [F5]
      • No need to handle manifest XML, OFS files, registry entries, etc. manually
      • Option to import Outlook-created OFS file
  • 20. Visual Ribbon Designer Property Grid Ribbon Control Toolbox Design Surface
  • 21. Building a VSTO Project
  • 22. Linq “ It is a mistake to try to look too far ahead. The chain of destiny can only be grasped one LINQ at a time.” ~Sir Winston Churchill (1874 - 1965) – modified slightly ;)
  • 23.
    • Linq has been over 7 years in the making
    • ObjectSpaces
      • PDC 2001
      • Supposed to be part of .Net 2.0
      • Linked to WinFS
    • C – Omega
      • Researched by Erik Meijer and Worlfram Schulte
      • Released as a preview in 2004
      • Language Extensions
      • Worked a lot with XML, Streams, Anonymous Structs
    • Linq
      • Backed by Anders Hejlsberg - Distinguished Engineer (Only 16 ever) – Chief Designer of C#
        • Matt Warren – Chief Engineer
        • Luca Bolognese– Lead Developer
    Very Brief Linq History
  • 24.
    • Integrate Objects, Relational Data & XML
    • SQL and Xquery-like power in C# and VB
    • Extensible Model for languages
    • Type Safety
    • Extensive IntelliSense support
    • Debugger Support
    • Run on the .Net 2.0 CLR
    • 100% backwards compatible
    Linq Goals
  • 25. Language INtegrated Query (LINQ) LINQ enabled data sources LINQ To Objects Objects LINQ To XML <book> <title/> <author/> <price/> </book> XML LINQ enabled ADO.NET LINQ To DataSets LINQ To SQL LINQ To Entities Relational Others… VB C# .NET Language-Integrated Query
  • 26. Channel 9 Videos Future of Languages : Anders Hejlsberg, Herb Sutter, Erik Meijer, Brian Beckman 513778
  • 27. Linq Query Syntax “ Syntax, my lad. It has been restored to the highest place in the republic.” ~John Steinbeck
  • 28. Linq Syntax – Why we started where we did var query = dc.Recipes .W here (r => r.Title.Contains( “Chocolate” ) ) .S elect (r => new{ r .Title, r.NumberOfServings}) ; Extension methods Lambda expressions Object initializers Anonymous types Implicitly Declared Local Variables Extension methods
  • 29. Standard Query Operators
    • These work similarly to their SQL counterparts
      • Select
      • Where
      • OrderBy/ThenBy
      • OrderByDescending/ThenByDescending
      • GroupBy
      • Count
      • Sum/Min/Max/Average
  • 30. Set Based Query Operators
    • Combine two sets of elements
      • Union
        • Returns all distinct elements in both sets
      • Intersection
        • Returns only elements belonging to both sets
      • Except
        • Returns elements in Set A but not in Set B
      • Repeat
        • Returns multiple copies of a set of elements
      • Distinct
        • Removes duplicate elements
  • 31. Projection That Creates a Nested 1-Many Collection
    • A query can be nested inside another query to produce a 1-Many Collection
    • var q = from c in db.Customers where c.City == &quot;London&quot; select new { c.CompanyName, c.Phone, OrderDates = ( from o in c.Orders select o.OrderDate) .Take(5) };
    • foreach( var c in q ) {
    • Console.WriteLine( c.CompanyName );
    • foreach( od in c.OrderDates )
    • Console.WriteLine( od )
    • }
  • 32. LINQ Queries Are Lazy
    • Assigning a query to an IEnumerable<T> variable doesn’t execute the query
    • When user iterates over members of the collection, each query operator executes as many times as needed to retrieve the next element
      • Hence the data can change while elements are still being retrieved
    • Use .ToList<T> or .ToArray<T> to force iteration over the entire query in one statement
      • Creates a snapshot copy of the original data
  • 33.
    • Every syntactic query expression in C# begins with a &quot; from &quot; clause and ends with either a &quot; select &quot; or &quot; group &quot; clause. 
      • The &quot; from &quot; clause indicates what data you want to query. 
      • The &quot; select &quot; clause indicates what data you want returned, and what shape it should be in.
    • For example, let's look again at the query against the List<Person> collection:
    Syntax – From a list (Linq to Objects)
  • 34.
    • If we query from a Database we use the same syntax.
    • We will cover the DataContext soon
    Syntax – From a DB
  • 35.
    • What goes on under the covers?
    • You write this :
    • Linq sends this to the database
    Syntax – Under the hood
  • 36.
    • What about complex queries?
    • You write this :
    • Linq sends this to the database
    Syntax – Under the hood Extension methods
  • 37. Why are SELECT and FROM Reversed
    • In C# 3.0, the IDE still doesn’t do background compilation, so it has to parse code line-by-line
      • Putting SELECT before FROM would prevent IntelliSense from knowing what can be SELECTed
  • 38. Defining the Data Model Classes
  • 39.
    • The DataContext Object is what links the class entities to the database entities.
    • This can be done by hand OR by using the Linq to SQL Class Model
    The DataContext Object
  • 40. Enabling a class
    •   [Table(Name = &quot;Customer&quot;)]
    •     public class Customer
    •     {
    •         private int _Id;
    •         private string _Name;
    •         private string _Phone;
    •          [Column(Id = true, Name = &quot;Id”)]
    •         public int Id { get { return _Id; } set { _Id = value; } }
    •         [Column(Name = &quot;Name&quot;)]
    •         public string Name { get { return _Name; } set { _Name = value; } }
    •         [Column(Name = &quot;PhoneNumber&quot;)]
    •         public string Phone { get { return _Phone; } set { _Phone = value; } }
    •     }
    But doing this manually is not required.!
  • 41. Adding LINQ to our VSTO App
  • 42. Summary
    • Microsoft Office is a unified solutions platform for building Office Business Applications that make line-of-business systems, enterprise data and workflows accessible and relevant to users
    • VSTO is the premiere developer tool for developing Office Business Applications and scalable enterprise grade solutions utilizing Visual Studio and Microsoft Office
    • VSTA is the key developer tool technology that enables ISVs to provide rich customization capabilities within their products and solutions
  • 43. Resources
    • Newsgroups and web forum
      • microsoft.public.officedev
    • VSTO-related blogs
      • VSTO Team Blog –
      • Eric Carter (VSTO Team Member) -
      • Andrew Whitechapel (VSTO Team Member) -
      • John Durant (VSTO Team Member) -
      • Paul Stubbs (VSTO Team Member) –
      • Mike Hernandez (VSTO Product Manager) –
      • Kathleen McGrath (UE Team Writer) -
      • Office Zealot Site (Tim Huckaby) -
  • 44. For More Information
    • Visit the VSTO Developer Center
    • Visit the VSTO 2005 SE web page
    • VSTO Help documentation on MSDN
  • 45. TechDays Technology Pilots
    • TechDays survey – informing business and technology reporters
        • Bluetooth opt in
        • Text “survey” to 95495
        • Privacy policy
    • TechDays “Resources on Demand”
        • Text TuesATwo to 95495
        • Respond with preferred email address
        • Resources/links from this session will be pushed to you via email
    • Wireless internet available in the lobby area
    • SSID: “TechDays”, no passcode
    • Provided by iBahn, hospitality broadband leader
    • Internet kiosks also available in the registration area after check-in
    • Text Messaging
    • Wireless Internet
  • 46. Event IDs for Template Session Title Text Message Keyword (send to 95495) SQL Roadshow TuesAOne MSDN: What’s New for Developers: Highlights from PDC TuesATwo Partner: Microsoft Licensing and Solution Update TuesBOne TechNet: Windows Vista, Powershell and Group Policy WedsAOne MSDN: SQL 2008, VSTO, Silverlight 2.0 WedsATwo SB2 at TS2: Solution Building for System Builders TS2 Partner Event: SBS/EBS, Response Point VoIP, and S+S! WedsBOne WedsBtwo TechNet: Virtualization and Enterprise Search ThursAOne MSDN: The Role of the Architect: Today and in the Future ThursATwo Momentum: Solution Briefing for IT and Business Executives ThursBOne Momentum Supersize Event ThursBTwo Dynamics ERP Briefing ThursCOne Partner: BPOS Deep Dive ThursCTwo
  • 47. Your Feedback is Important
    • 1 . Which technology has your organization purchased, but not yet deployed, that would have the greatest ability to create cost savings?
    • 2. What technology has your organization not purchased that would have the greatest impact on cost savings?
    • 3. On a scale of 1-5 rate your company’s current level of interest for using IT to make the organization more environmentally friendly.
    • 4. On a scale of 1-5 how would you rate your organization’s interest in cloud-based solutions?
    • 1. On a scale of 1-5 (5=High, 1=Low), how would you rate your organization’s interest in investing in IT staff or resources within the next 12 months?
    • 2. What do you think is the biggest factor influencing your organization’s interest in investing in IT staff or resources within the next 12 months?
    • Microsoft Technology
    • IT Staffing and Resources
  • 48. Slides and Demos Slides can be found at: Demo code can be found at:
  • 49.