Daniel Egan Msdn Tech Days Oc Day2

1,652 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,652
On SlideShare
0
From Embeds
0
Number of Embeds
93
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Daniel Egan Msdn Tech Days Oc Day2

    1. 1. Daniel N. Egan Microsoft – Developer Evangelist http://www.DotNetDoc.com http://Twitter.com/DanielEgan Building a VSTO application using LINQ
    2. 2. <ul><li>Daniel Egan –Developer Evangelist Microsoft MCSD, </li></ul><ul><li>Former Microsoft Regional Director Microsoft MVP – ASP.Net, MCSD, MCT </li></ul><ul><li>Former INETA President </li></ul><ul><li>INETA Speakers Bureau </li></ul><ul><li>Author : Building Websites with VB.Net and DotNetNuke 3.0 Packt Publishing </li></ul><ul><li>.Net Certificate Instructor California State University Fullerton </li></ul><ul><li>CSUF .Net Advisory Board Member </li></ul><ul><li>Run DotNetDoc.com </li></ul><ul><li>Co-Founder – SoCalDotNet </li></ul><ul><li>TwitterID : DanielEgan </li></ul>Daniel Egan
    3. 3. <ul><li>INETA – International .Net Association </li></ul><ul><ul><li>www.Ineta.org </li></ul></ul><ul><li>User groups in this Area. </li></ul><ul><li>OCDotNet – www.OCDotNet.org </li></ul><ul><li>SoCalDotNet –www.SoCalDotNet.org </li></ul><ul><li>South Bay .Net - southbaynet.org/ </li></ul><ul><li>LADotNet –www.LADotNet.org </li></ul><ul><li>LA C# - www.LACSharp.org </li></ul><ul><li>SGV – www.SGVDotNet.org </li></ul><ul><li>Inland Empire – www.IEDotNetUG.org </li></ul>User Groups
    4. 4. <ul><li>m.Twitter.Com </li></ul><ul><li>#TechDays </li></ul><ul><li>http://www.Twitter.com/DanielEgan </li></ul>Twitter Your questions…
    5. 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
    7. 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
    8. 9. <ul><li>Integrated design-time experience </li></ul><ul><li>Increased security through .NET Framework </li></ul><ul><li>Document-level & application-level task pane customizations </li></ul><ul><li>… </li></ul><ul><li>Support for managed controls </li></ul><ul><li>Support for host controls </li></ul><ul><li>Ability to add controls at design-time or dynamically at run-time </li></ul><ul><li>… </li></ul><ul><li>Quick development </li></ul><ul><li>Competitive advantage </li></ul><ul><li>Strength of two major products </li></ul><ul><li>… </li></ul>
    9. 11. What About VBA?
    10. 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
    11. 13. Reasons for Using VSTO vs. VBA * There are no pending plans to retire VBA at this time <ul><li>VBA IS A 1990’S TECHNOLOGY </li></ul><ul><ul><li>Limited functionality and flexibility </li></ul></ul><ul><ul><li>Code in document = no source code/version control </li></ul></ul><ul><li>VISUAL STUDIO TOOLS FOR OFFICE IS 100% .NET </li></ul><ul><ul><li>Choice of Visual Basic .NET or C# </li></ul></ul><ul><ul><li>Pro dev environment & tools; access to .NET Framework </li></ul></ul><ul><li>VSTO SOLUTIONS ARE SECURE </li></ul><ul><ul><li>VBA has a casual security model = high potential security risk </li></ul></ul><ul><ul><li>VSTO solutions employ the .NET Security model </li></ul></ul><ul><li>VSTO SUPPORTS BUILDING SCALABLE OFFICE BUSINESS SOLUTIONS </li></ul><ul><ul><li>Take advantage of the 2007 Office system development platform </li></ul></ul><ul><ul><li>Utilize the full benefits of the Visual Studio development environment </li></ul></ul>
    12. 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?
    13. 15. Call VSTO from VBA <ul><li>Developers enable VBA via COM Interop </li></ul><ul><li>Interop implemented at design time </li></ul><ul><li>Developers can then call VSTO from VBA with IntelliSense after building the project </li></ul>
    14. 16. VSTO and 2007 Office System
    15. 17. Custom Task Panes <ul><li>VSTO 2005 SE provides app-level custom task panes </li></ul><ul><li>Create custom task panes with an add-in </li></ul><ul><li>Add-in support & task pane support for </li></ul><ul><ul><li>Project, Excel, InfoPath, Outlook, PowerPoint, Word </li></ul></ul><ul><li>Custom task panes appear in the main application window or (Outlook) inspectors </li></ul><ul><li>Populate custom task pane with UserControls </li></ul><ul><ul><li>Populate user controls with Winform controls </li></ul></ul>
    16. 18. Outlook Form Regions <ul><li>Implement a custom form region with an add-in </li></ul><ul><li>Runtime and design-time support </li></ul>
    17. 19. Outlook Form Region Wizard <ul><li>VSTO simplifies and speeds up Outlook form region design and configuration process with a visual designer </li></ul><ul><ul><li>Achieve maximum form region design flexibility with VS visual designer </li></ul></ul><ul><ul><li>Configure your form region with a simple, intuitive wizard </li></ul></ul><ul><ul><li>Run and debug your form region right from Visual Studio [F5] </li></ul></ul><ul><ul><li>No need to handle manifest XML, OFS files, registry entries, etc. manually </li></ul></ul><ul><ul><li>Option to import Outlook-created OFS file </li></ul></ul>
    18. 20. Visual Ribbon Designer Property Grid Ribbon Control Toolbox Design Surface
    19. 21. Building a VSTO Project
    20. 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 ;)
    21. 23. <ul><li>Linq has been over 7 years in the making </li></ul><ul><li>ObjectSpaces </li></ul><ul><ul><li>PDC 2001 </li></ul></ul><ul><ul><li>Supposed to be part of .Net 2.0 </li></ul></ul><ul><ul><li>Linked to WinFS </li></ul></ul><ul><li>C – Omega </li></ul><ul><ul><li>Researched by Erik Meijer and Worlfram Schulte </li></ul></ul><ul><ul><li>Released as a preview in 2004 </li></ul></ul><ul><ul><li>Language Extensions </li></ul></ul><ul><ul><li>Worked a lot with XML, Streams, Anonymous Structs </li></ul></ul><ul><li>Linq </li></ul><ul><ul><li>Backed by Anders Hejlsberg - Distinguished Engineer (Only 16 ever) – Chief Designer of C# </li></ul></ul><ul><ul><ul><li>Matt Warren – Chief Engineer </li></ul></ul></ul><ul><ul><ul><li>Luca Bolognese– Lead Developer </li></ul></ul></ul>Very Brief Linq History
    22. 24. <ul><li>Integrate Objects, Relational Data & XML </li></ul><ul><li>SQL and Xquery-like power in C# and VB </li></ul><ul><li>Extensible Model for languages </li></ul><ul><li>Type Safety </li></ul><ul><li>Extensive IntelliSense support </li></ul><ul><li>Debugger Support </li></ul><ul><li>Run on the .Net 2.0 CLR </li></ul><ul><li>100% backwards compatible </li></ul>Linq Goals
    23. 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
    24. 26. Channel 9 Videos Future of Languages : Anders Hejlsberg, Herb Sutter, Erik Meijer, Brian Beckman http://tinyurl.com/ 513778
    25. 27. Linq Query Syntax “ Syntax, my lad. It has been restored to the highest place in the republic.” ~John Steinbeck
    26. 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
    27. 29. Standard Query Operators <ul><li>These work similarly to their SQL counterparts </li></ul><ul><ul><li>Select </li></ul></ul><ul><ul><li>Where </li></ul></ul><ul><ul><li>OrderBy/ThenBy </li></ul></ul><ul><ul><li>OrderByDescending/ThenByDescending </li></ul></ul><ul><ul><li>GroupBy </li></ul></ul><ul><ul><li>Count </li></ul></ul><ul><ul><li>Sum/Min/Max/Average </li></ul></ul>
    28. 30. Set Based Query Operators <ul><li>Combine two sets of elements </li></ul><ul><ul><li>Union </li></ul></ul><ul><ul><ul><li>Returns all distinct elements in both sets </li></ul></ul></ul><ul><ul><li>Intersection </li></ul></ul><ul><ul><ul><li>Returns only elements belonging to both sets </li></ul></ul></ul><ul><ul><li>Except </li></ul></ul><ul><ul><ul><li>Returns elements in Set A but not in Set B </li></ul></ul></ul><ul><ul><li>Repeat </li></ul></ul><ul><ul><ul><li>Returns multiple copies of a set of elements </li></ul></ul></ul><ul><ul><li>Distinct </li></ul></ul><ul><ul><ul><li>Removes duplicate elements </li></ul></ul></ul>
    29. 31. Projection That Creates a Nested 1-Many Collection <ul><li>A query can be nested inside another query to produce a 1-Many Collection </li></ul><ul><li>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) }; </li></ul><ul><li>foreach( var c in q ) { </li></ul><ul><li>Console.WriteLine( c.CompanyName ); </li></ul><ul><li>foreach( od in c.OrderDates ) </li></ul><ul><li>Console.WriteLine( od ) </li></ul><ul><li>} </li></ul>
    30. 32. LINQ Queries Are Lazy <ul><li>Assigning a query to an IEnumerable<T> variable doesn’t execute the query </li></ul><ul><li>When user iterates over members of the collection, each query operator executes as many times as needed to retrieve the next element </li></ul><ul><ul><li>Hence the data can change while elements are still being retrieved </li></ul></ul><ul><li>Use .ToList<T> or .ToArray<T> to force iteration over the entire query in one statement </li></ul><ul><ul><li>Creates a snapshot copy of the original data </li></ul></ul>
    31. 33. <ul><li>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.  </li></ul><ul><ul><li>The &quot; from &quot; clause indicates what data you want to query.  </li></ul></ul><ul><ul><li>The &quot; select &quot; clause indicates what data you want returned, and what shape it should be in. </li></ul></ul><ul><li>For example, let's look again at the query against the List<Person> collection: </li></ul>Syntax – From a list (Linq to Objects)
    32. 34. <ul><li>If we query from a Database we use the same syntax. </li></ul><ul><li>We will cover the DataContext soon </li></ul>Syntax – From a DB
    33. 35. <ul><li>What goes on under the covers? </li></ul><ul><li>You write this : </li></ul><ul><li>Linq sends this to the database </li></ul>Syntax – Under the hood
    34. 36. <ul><li>What about complex queries? </li></ul><ul><li>You write this : </li></ul><ul><li>Linq sends this to the database </li></ul>Syntax – Under the hood Extension methods
    35. 37. Why are SELECT and FROM Reversed <ul><li>In C# 3.0, the IDE still doesn’t do background compilation, so it has to parse code line-by-line </li></ul><ul><ul><li>Putting SELECT before FROM would prevent IntelliSense from knowing what can be SELECTed </li></ul></ul>
    36. 38. Defining the Data Model Classes
    37. 39. <ul><li>The DataContext Object is what links the class entities to the database entities. </li></ul><ul><li>This can be done by hand OR by using the Linq to SQL Class Model </li></ul>The DataContext Object
    38. 40. Enabling a class <ul><li>  [Table(Name = &quot;Customer&quot;)] </li></ul><ul><li>    public class Customer </li></ul><ul><li>    { </li></ul><ul><li>        private int _Id; </li></ul><ul><li>        private string _Name; </li></ul><ul><li>        private string _Phone; </li></ul><ul><li>  </li></ul><ul><li>         [Column(Id = true, Name = &quot;Id”)] </li></ul><ul><li>        public int Id { get { return _Id; } set { _Id = value; } } </li></ul><ul><li>  </li></ul><ul><li>        [Column(Name = &quot;Name&quot;)] </li></ul><ul><li>        public string Name { get { return _Name; } set { _Name = value; } } </li></ul><ul><li>  </li></ul><ul><li>        [Column(Name = &quot;PhoneNumber&quot;)] </li></ul><ul><li>        public string Phone { get { return _Phone; } set { _Phone = value; } } </li></ul><ul><li>    } </li></ul>But doing this manually is not required.!
    39. 41. Adding LINQ to our VSTO App
    40. 42. Summary <ul><li>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 </li></ul><ul><li>VSTO is the premiere developer tool for developing Office Business Applications and scalable enterprise grade solutions utilizing Visual Studio and Microsoft Office </li></ul><ul><li>VSTA is the key developer tool technology that enables ISVs to provide rich customization capabilities within their products and solutions </li></ul>
    41. 43. Resources <ul><li>Newsgroups and web forum </li></ul><ul><ul><li>microsoft.public.vsnet.vstools.office </li></ul></ul><ul><ul><li>microsoft.public.officedev </li></ul></ul><ul><ul><li>microsoft.public.office.developer </li></ul></ul><ul><ul><li>http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=16 </li></ul></ul><ul><li>VSTO-related blogs </li></ul><ul><ul><li>VSTO Team Blog – http://blogs.msdn.com/vsto2 </li></ul></ul><ul><ul><li>Eric Carter (VSTO Team Member) - http://blogs.msdn.com/eric_carter/ </li></ul></ul><ul><ul><li>Andrew Whitechapel (VSTO Team Member) - http://blogs.msdn.com/andreww/default.aspx </li></ul></ul><ul><ul><li>John Durant (VSTO Team Member) - https://blogs.msdn.com/johnrdurant/default.aspx </li></ul></ul><ul><ul><li>Paul Stubbs (VSTO Team Member) – http://blogs.msdn.com/pstubbs/ </li></ul></ul><ul><ul><li>Mike Hernandez (VSTO Product Manager) – http://blogs.msdn.com/mikeh/default.aspx </li></ul></ul><ul><ul><li>Kathleen McGrath (UE Team Writer) - http://blogs.msdn.com/kathleen </li></ul></ul><ul><ul><li>Office Zealot Site (Tim Huckaby) - http://www.officezealot.com/VSTO/bloghome.aspx </li></ul></ul>
    42. 44. For More Information <ul><li>Visit the VSTO Developer Center </li></ul><ul><ul><li>http://msdn.microsoft.com/office/tool/vsto/default.aspx </li></ul></ul><ul><li>Visit the VSTO 2005 SE web page </li></ul><ul><ul><li>http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86CAB3-6FD6-4955-B979-E1676DB6B3CB </li></ul></ul><ul><li>VSTO Help documentation on MSDN </li></ul><ul><ul><li>http://msdn2.microsoft.com/library/d2tx7z6d(en-us,vs.80).aspx </li></ul></ul>
    43. 45. TechDays Technology Pilots <ul><li>TechDays survey – informing business and technology reporters </li></ul><ul><ul><ul><li>Bluetooth opt in </li></ul></ul></ul><ul><ul><ul><li>Text “survey” to 95495 </li></ul></ul></ul><ul><ul><ul><li>Privacy policy </li></ul></ul></ul><ul><li>TechDays “Resources on Demand” </li></ul><ul><ul><ul><li>Text TuesATwo to 95495 </li></ul></ul></ul><ul><ul><ul><li>Respond with preferred email address </li></ul></ul></ul><ul><ul><ul><li>Resources/links from this session will be pushed to you via email </li></ul></ul></ul><ul><li>Wireless internet available in the lobby area </li></ul><ul><li>SSID: “TechDays”, no passcode </li></ul><ul><li>Provided by iBahn, hospitality broadband leader </li></ul><ul><li>Internet kiosks also available in the registration area after check-in </li></ul><ul><li>Text Messaging </li></ul><ul><li>Wireless Internet </li></ul>
    44. 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
    45. 47. Your Feedback is Important <ul><li>1 . Which technology has your organization purchased, but not yet deployed, that would have the greatest ability to create cost savings? </li></ul><ul><li>2. What technology has your organization not purchased that would have the greatest impact on cost savings? </li></ul><ul><li>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. </li></ul><ul><li>4. On a scale of 1-5 how would you rate your organization’s interest in cloud-based solutions? </li></ul><ul><li>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? </li></ul><ul><li>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? </li></ul><ul><li>Microsoft Technology </li></ul><ul><li>IT Staffing and Resources </li></ul>
    46. 48. Slides and Demos Slides can be found at: Demo code can be found at: www.DotNetDoc.com

    ×