This document summarizes a presentation on building VSTO applications using LINQ. The presentation covers the fundamentals of VSTO development, how and why to use LINQ, and includes demos. Reasons for using VSTO over VBA are discussed, as well as how to add LINQ to a VSTO application.
Report
Share
Report
Share
1 of 49
More Related Content
Daniel Egan Msdn Tech Days Oc Day2
1. Daniel N. Egan Microsoft – Developer Evangelist http://www.DotNetDoc.com http://Twitter.com/DanielEgan 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 DotNetDoc.com Co-Founder – SoCalDotNet TwitterID : DanielEgan Daniel Egan
3. INETA – International .Net Association www.Ineta.org User groups in this Area. OCDotNet – www.OCDotNet.org SoCalDotNet –www.SoCalDotNet.org South Bay .Net - southbaynet.org/ LADotNet –www.LADotNet.org LA C# - www.LACSharp.org SGV – www.SGVDotNet.org Inland Empire – www.IEDotNetUG.org User Groups
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 …
13. Reasons for Using VSTO vs. VBA * There are no pending plans to retire VBA at this time VBA IS A 1990’S TECHNOLOGY Limited functionality and flexibility Code in document = no source code/version control VISUAL STUDIO TOOLS FOR OFFICE IS 100% .NET Choice of Visual Basic .NET or C# Pro dev environment & tools; access to .NET Framework VSTO SOLUTIONS ARE SECURE VBA has a casual security model = high potential security risk VSTO solutions employ the .NET Security model VSTO SUPPORTS BUILDING SCALABLE OFFICE BUSINESS SOLUTIONS 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
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
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 http://tinyurl.com/ 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 == "London" 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 " from " clause and ends with either a " select " or " group " clause. The " from " clause indicates what data you want to query. The " select " 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
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 = "Customer")] public class Customer { private int _Id; private string _Name; private string _Phone; [Column(Id = true, Name = "Id”)] public int Id { get { return _Id; } set { _Id = value; } } [Column(Name = "Name")] public string Name { get { return _Name; } set { _Name = value; } } [Column(Name = "PhoneNumber")] public string Phone { get { return _Phone; } set { _Phone = value; } } } But doing this manually is not required.!
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.vsnet.vstools.office microsoft.public.officedev microsoft.public.office.developer http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=16 VSTO-related blogs VSTO Team Blog – http://blogs.msdn.com/vsto2 Eric Carter (VSTO Team Member) - http://blogs.msdn.com/eric_carter/ Andrew Whitechapel (VSTO Team Member) - http://blogs.msdn.com/andreww/default.aspx John Durant (VSTO Team Member) - https://blogs.msdn.com/johnrdurant/default.aspx Paul Stubbs (VSTO Team Member) – http://blogs.msdn.com/pstubbs/ Mike Hernandez (VSTO Product Manager) – http://blogs.msdn.com/mikeh/default.aspx Kathleen McGrath (UE Team Writer) - http://blogs.msdn.com/kathleen Office Zealot Site (Tim Huckaby) - http://www.officezealot.com/VSTO/bloghome.aspx
44. For More Information Visit the VSTO Developer Center http://msdn.microsoft.com/office/tool/vsto/default.aspx Visit the VSTO 2005 SE web page http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86CAB3-6FD6-4955-B979-E1676DB6B3CB VSTO Help documentation on MSDN http://msdn2.microsoft.com/library/d2tx7z6d(en-us,vs.80).aspx
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: www.DotNetDoc.com