Tag Archives: Microsoft

Why Microsoft Word Training is a Wise Decision

Given the wide array of new and complex technologies in the modern workplace, dedicated training for Microsoft Word might seem at first blush somewhat superfluous. Word is, after all, among the most venerable and commonplace of software applications. What’s to learn?

Yet, those taking Word for granted are likely missing the marked evolution of program from a simple, electronic word processor to a comprehensive communications platform, notes Leeanne McManus, Chief Learning & Talent Officer, ikuw Solutions, Inc. Employees content to just scratch the surface and not delve into the advanced functionalities added to Word in recent versions may be unwittingly costing themselves time and effort by manually performing tasks that could easily be automated.

Leeanne resized

Leeanne McManus

“Some people will say ‘I’ve had this program for 15 years, why would I need more training?’” McManus says. “They don’t understand the lost productivity and missed chances for collaboration when you are manually doing things.”

According to McManus, the need for Word training is now especially pronounced as Microsoft has looked to reshape Word in recent releases in order to account for larger trends in technology such as cloud computing, appification and mobility. For example, recent versions of Word feature a flat design ascetic, a purposeful decision made to accommodate people using their fingers to navigate the program on devices such as phones and tablets. Nonetheless, this decision may have unintentionally led to confusion for longtime desktop users, she notes. “One of The biggest pain points for people accustomed to older versions of Word was getting used to the flatness,” she says. “If you came from anything before Word 2007, the new versions such Word 2013 of Word 2016 are going to seem completely foreign. Other than the basic functionality, you may as well have been using WordPerfect.”

In addition to just figuring out where they moved everything, Word training is also becoming essential as the program shifts to the cloud and becomes more tightly integrated with a variety of Microsoft collaboration and desktop products including Sharepoint, OneNote and Outlook. Given the overlapping functionality and the common design language of these programs, an employee efficient on Word will have a head start understanding these programs and how they interrelate. “Word has gone from being a program to being a platform,” she says.

Indeed, given the program’s ubiquity in the office place, training employees to get the most out of Word may prove an effective icebreaker for getting them to better leverage all the technologies your enterprise has to offer. “Some people are by nature afraid to explore,” McManus says. “They are terribly afraid they will break something or cause World War 3. It’s just software.”

 

About the Author

Kenealy resizedBill Kenealy is a copywriter and blogger specializing in enterprise technologies. A graduate of the University of Kansas with a degree in journalism, Bill has 15 years of experience reporting on business and IT. Bill recently relocated to the Twin Cities and enjoys travel and exploring his new home state with his wife. He enjoys reading, PC gaming and watching football by himself.

MVC 6: Your Web Development World is About to Get Rocked!

If you missed the live-stream of our latest webinar on 7/22/2015, never fear! Check out the link below to get yourself up to speed with MVC 6. The webinar is led by instructor and skijoring enthusiast, Don Kiely, and I should warn you in advance …it will rock your world!

For years, Microsoft did its best in battling rapid changes with the Internet to keep its ASP.NET and MVC technology up to speed. However; it’s been nearly 15 years since ASP.NET first hit the web, and those changes simply became too dramatic to overcome.

Enter Visual Studio 2015, Microsoft’s way of throwing out the “old ASP.NET manual” and rebuilding things from the ground up. Visual Studio 2015 was released on 7/20/2015, along with the .NET Framework 4.6 and updated web development tools. With MVC being part of ASP.NET, it has strapped itself in and come along for the update adventure!

This massive update now sees MVC boasting new features like broad support for new web technologies, as well as editor updates for JSON, HTML, and JavaScript. It will also now be much easier and more fun (!) to write robust web applications thanks to tools like HTML5 and CSS.

So this is a big deal?

Absolutely! Not only is the jump from ASP.NET to ASP.NET 5 as significant as switching from Classic ASP to ASP.NET was, but this bad boy is also open source! MVC, Web API, and Web Pages have been combined into a single unified open source programming model, which is hosted on GitHub. There are new tag helpers, view components, simpler dependency management, dependency injection, and more!

As you can see, there is suddenly a lot of stuff to learn about the all new Visual Studio 2015. With our new webinar, you will get a high level look at the newest MVC 6 and ASP.NET 5 features, as well as a jumpstart on building web applications using the new Microsoft stack. Instructor Don Kiely will walk you through these new and exciting changes and features, and have you ready to be a Visual Studio superstar in no time.

Check out the link below (it’s free)…just be sure to turn the volume up to eleven!

http://www.learnnowonline.com/webinars

NOTE: Both MVC 6 and ASP.NET 5 are included with this release; however, you cannot yet use them for production purposes.

The RC1 (release candidate 1) for ASP.NET 5 is slated for release in November 2015, which will have a “Go Live License”. This “Go Live License” indicates that Microsoft is ready to fully support ASP.NET 5 and MVC 6 and that they are confident that users will be able to use the technologies for production applications.

A helpful roadmap of release dates can be viewed here:

https://github.com/aspnet/Home/wiki/Roadmap

About the Author:


zach2-300x225Zach Young
 manages the LearnNowOnline customer support department. In addition to making strange but surprisingly delicious smoothies, Zach divides his time between the LearnNowOnline recording studio, providing sales demos for new and existing clients, and ensuring that each customer is taken care of. In his spare time, Zach enjoys globetrotting with his wife, playing and recording music, and attempting to get the required 1.21 gigawatts for Doc Brown’s DeLorean.

 

Types of Features

Most of the elements in a SharePoint installation are either defined using features or leverage features in some way. Accordingly, there are feature types that define most of the site elements with which you are already familiar.

Feature/Site Template Association

Feature/site template associations allow you to associate new features and functionality with existing site definitions or site templates so that, when you provision a site, SharePoint automatically activates the features. This technique is known as feature stapling.

Feature stapling makes versioning much easier because it allows you to associate new features with preexisting site definitions. Stapled features also provide an excellent way to handle situations that require activation code, because they are applied after their associated site is fully provisioned.

Two features are involved in feature stapling: the feature that contains the functionality you want to add to an existing site template, and the feature/site template association feature. Feature/site template associations have Farm or WebApplication scope.

You can globally associate a feature with every site definition on a farm. Associate a feature with the global site definition by specifying GLOBAL for the TemplateName attribute. Whenever you create a site, the global site definition is applied, so your feature is also applied.

Workflow

Use a workflow feature to attach a custom workflow to SharePoint. The feature includes the code for the workflow and the necessary forms for each step.

Document Converter

Document converters automatically convert a document library item from one format to another. WSS does not offer document converters, but MOSS includes several (for example, to convert documents to HTML) and third-party converters to support conversion to PDF and other formats.

Site Columns and Content Types

In features, you define site columns with a Field element. All of the core site columns are defined in a feature named fields that is activated by the global site definition. You can use the fields feature as a reference when creating your own site columns or content types.

Just as the global site definition activates the fields feature for site columns, the ctypes feature is also activated globally for content types. You can create a new content type with a feature using the ContentType feature element.

Sometimes, you will need to associate a content type with an existing list or alist that another feature created as part of a larger solution. Use the ContentTypeBinding feature type for that task.

Lists

You can define a new type of list—including content type associations, views, and custom forms—with a ListTemplate feature. Each of the standard lists and libraries is defined by a ListTemplate feature element. For example, the DocumentLibrary feature defines the Document Library template.

You can create new list instances by using ListInstance to specify the target URL and the list template that defines the list.

SharePoint exposes a rich event model for lists that allows custom code to run whenever something happens to a list or an item. Use the Receivers feature type to associate the assembly and a class that contains a handler for a specific event type to all lists defined by a particular list template.

Module

The Module feature allows you to deploy files to a site. You can use it to add files to a library or simply place the files onto the site in a specified folder. In the latter case, the module creates the folder if necessary.

Control

You might expect the Control feature to install controls, but it doesn’t. Many of the core site pages use a Web control named DelegateControl. DelegateControl is a placeholder; when the page renders, it loads a concrete control instance that is based on an ID and a sequence number. DelegateControl looks for the lowest sequence number of a given ID and loads
the associated control. Individual Control features define the IDs and sequence numbers.

This feature allows site owners to override existing controls with their own specialized instances on existing sites, without altering the sites or their definitions. A common use of this technique is to replace the basic search control, which is defined by a DelegateControl on the master page with an ID of SmallSearchInputBox. You can replace this control when you brand a site by deploying your own control or Web Part and then creating a Control feature with the SmallSearchInputBox identifier and a low sequence number.

Custom Actions

Just as Control allows you to insert controls in defined placeholders without changing the target site or pages, the Custom Actions feature allows you to insert or hide links on pages and menus. CustomAction and HideCustomAction both require that you specify a location, and they affect the resulting page without directly altering its definition.

Use Custom Actions to show or hide different elements of the site, including the contents of many drop-down menus such as site actions, personal settings, list settings, and item edit menus. You can also use Custom Actions to show and hide links on the Site Settings page and on the Create Libraries, Lists, And Sites page. Custom actions enable greater control of additional navigation within the site than you can accomplish with the top-level menus.
You can use custom actions to display an option on the edit item menu of a list or document library’s items. For example, you could display a link to a function that merges a contact item’s data with a document template to create a form letter.

New Feature Elements in 2010

SharePoint 2010 adds a number of feature elements to the schema.

Property Bag

The PropertyBag element allows you to add properties to items in a site. The Save Site as Template functionality uses PropertyBag to create solutions that can duplicate the source site with high fidelity.

When using a PropertyBag to target a file, the use is identical to the Properties child element of the File element within a module. The difference is that the PropertyBag is independent of the need to deploy the file. In other words, you can apply properties to items that already exist.

Web Template

The WebTemplate element provides an alternative to traditional site templates. In most cases this element is now the preferred method for creating new templates for custom sites.

Workflow Association

The WorkflowAssociation allows declarative association of a workflow template to a list, content type, or site. Previously you had to use managed code to create a workflow association. Managed code is still a fully supported option.

Others

The feature schema definition, wss.xsd, includes four other workflow elements that are currently undocumented and unused by any of the built-in features that come with SharePoint 2010. They are:

  • Workflow Actions
  • Web Part Adder Extension
  •  User Migrator
  • Group Migrator

Doug (SPC  towards the end of the smile clip)This post is an excerpt from the online courseware for our Microsoft SharePoint 2010 for Developers course written by expert Doug Ware.

Doug Ware is a SharePoint expert and an instructor for many of our SharePoint 2007 and SharePoint 2010 courses. A Microsoft MVP several times over, Doug is the leader of the Atlanta .NET User Group, one of the largest user groups in the Southeast U.S., and is a frequent speaker at code camps and other events. In addition to teaching and writing about SharePoint, Doug stays active as a consultant and has helped numerous organizations implement and customize SharePoint.

Review of DataSets

VisualStudio2010ADO.NET provides the ability to retrieve data from any number of data sources and to work with that data in memory. The DataSet object represents a local cache of data that is disconnected from the original source. The DataSet object can provide a relational view of data: It can contain tables, columns, rows, constraints, and relationships. The DataTable object represents one table of in-memory data. It supports rows and columns with schema information, much like an array, but it’s far more powerful. You can retrieve a DataTable by retrieving data from a data source, or you can create and fill the DataTable manually. The DataTable class exposes collections of rows and columns, where a row represents a reference to an actual row of data, and a column contains information about the schema for one of the columns of data. A DataTable’s Rows property contains a collection of DataRow objects, and its Columns property contains a collection of DataColumn objects. You can access and manipulate data in a DataTable’s rows by using a DataRow object. When you work with the Rows property of the DataTable, you can:

  • Access a DataRow object within the Rows collection by index, enumerator, or lookup.
  • Iterate through all rows, using a DataRow object as the iterator.
  • Iterate through all the rows, using an integer as the indexer.
  • Use the NewRow method of the Rows collection to add a new row, which returns a new DataRow object.

DataSets can be untyped or typed. When you directly instantiate the DataSet class, as shown in the following code, you will have an untyped DataSet.

A typed DataSet inherits from the DataSet class. It contains strongly typed properties for each DataTable. This means you can refer to tables and columns by names. If you are using an untyped DataSet, you can refer to the Products table by using myDataSet.Tables(“Products”). You can refer to the ProductID column in the Products table by using myDataSet.Tables(“Products”).Columns(“ProductID”). If you are working with a typed DataSet, you can use myDataSet.Products to refer to the table and myDataSet.Products.ProductID to refer to the column. When you create a data source via the Data Source Configuration Wizard, Visual Studio creates a typed DataSet that includes the tables you specify.

ldn-expertkgetzThis post is an excerpt from the online courseware for our Microsoft LINQ Using Visual C# 2010 course written by expert Ken Getz.

Ken Getz is a Visual Studio expert with over 25 years of experience as a successful developer and consultant. He is a nationally recognized author and speaker, as well as a featured instructor for LearnNowOnline.

Advanced Query Techniques

Thumbnail for 578

The T-SQL INSERT, UPDATE, and DELETE statements provide a lot of power and flexibility for maintaining data in a relational database. But they can also be unwieldy. Say that you have a table with rows that you need to use to update another table. Depending on the data in the source table, you might have to update or delete an existing row or, if no related row exists, insert it into the table. This can be unwieldy, requiring several statements to perform the various actions. And it can be a pain to get all the comparisons working just right.

The MERGE statement addresses this issue. It lets you insert, update, and delete table data with just a single statement, based on the similarities and differences in the data. It joins a data source table with a target table or view to perform the various actions. The operation it performs depends on the results of the join:

  • If data exists in both the source and the target, update the changed data in the target.
  • If data in the source doesn’t exist in the target, insert data into the target.
  • If data exists in the target but not in the source, delete the data from the target.

You have full control over how you define whether and how each of these actions will occur for a particular row in the source table. The MERGE statement is transactional, so you don’t need to explicitly define a transaction.
If any of the operations fails, the entire statement rolls back.

  • The MERGE statement uses five clauses:
  • The MERGE clause specifies the target data, such as a table, view, or other query.
  • The USING clause defines the source data.
  • The ON clause specifies how to join the tables, much like a regular JOIN clause.
  • One or more WHEN clauses define the actions to take based on the join matching.
  • The OUTPUT clause returns a row for each action taken.

The WHEN clause is where all the actions occur, and you’re likely to have more than one in a typical MERGE statement. The WHEN clause has three forms:

  •  WHEN MATCHED [AND condition]

Here is where you either update or delete an existing row in the target
data. You can have at most two of these clauses, and if you have two,
one must have a condition associated with it. You can define either an
UPDATE or DELETE statement in this clause. If you’re using an
UPDATE statement and more than one row in the target matches the
statement, you get an error, and you can’t update any row in the target
more than once. Similarly, you can’t update and delete the same row.

  •  WHEN NOT MATCHED [BY TARGET] [AND condition]

This is where you can use an INSERT statement, when a row in the source doesn’t match any row in the target. You can have only one of this WHEN form in any MERGE statement. The BY TARGET clause is optional, because it is the default.

  •  WHEN NOT MATCHED BY SOURCE [AND condition]

This form of the WHEN clause kicks in when rows in the target don’t match a row in the source; in this case you can either update or delete the row in the target. You can have at most two of these in a MERGE statement, and the second must have a condition associated with it. 

The optional condition on some of the versions of the WHEN clause can be  just about anything you can include in a WHERE clause. You have to include  at least one WHEN clause in the MERGE statement, although the order you include the different forms doesn’t matter at all. What does matter is that if you include the same form with and without a condition, the clause with the condition must be first.

Any triggers that exist on the affected target table will fire normally, but there is no guarantee of the order in which triggers fire if multiple operations are performed on the target table. So be careful of side effects. All normal permissions apply, so the user or security context must be able to perform the various actions.
ldn-expertdkielyThis post is an excerpt from the online courseware for our Microsoft SQL Server 2012 Developer course written by expert Don Kiely. 

Don Kiely is a featured instructor on many of our SQL Server and Visual Studio courses. He is a nationally recognized author, instructor and consultant who travels the country sharing his expertise in SQL Server and security.

LINQ to SQL Read-Only Queries

If you are looking for maximum performance, you can execute your queries in read-only mode. To do that, you can set the ObjectTrackingEnabled property of the DataContext to false. This turns off change tracking, which has some overhead. Because LINQ to SQL does not track changes in this mode, performance improves.

When you select Read Only Queries in the chapter’s sample application, you
will execute two queries. The first retrieves a list of customers in the United
States.

The second query illustrates an important consequence of setting
ObjectTrackingEnabled to false: It sets DeferredLoadingEnabled to false and
therefore turns off deferred loading.

Figure below shows the result of running this code.
TopicLINQtoSQLimg1
Figure above Deferred loading is disabled, so the number of orders does not display.

The code first executes a query to retrieve information for a customer. It then displays the customer’s name, city, and region. Next, the code displays the number of orders for this customer. In the previous example, LINQ to SQL then generated a SQL statement to retrieve the customer’s orders. However, when you turn off change tracking you turn off deferred loading, so in this case, LINQ to SQL does not send the SQL statement to retrieve the customer’s orders.

The code next defines the following query to retrieve the ID and value for each order. However, customer.Orders is empty, so LINQ to SQL does not generate the SQL statement to retrieve the data.

 

TIP: Use read-only queries with caution. The absence of deferred loading means you will not retrieve all of the data you would otherwise. If your code relies on the missing data, you could receive runtime errors.

ldn-expertkgetzThis post is an excerpt from the online courseware for our Microsoft LINQ Using Visual C# 2010 course written by expert Ken Getz.

Ken Getz is a Visual Studio expert with over 25 years of experience as a successful developer and consultant. He is a nationally recognized author and speaker, as well as a featured instructor for LearnNowOnline.

Record Management in SharePoint 2010

Thumbnail for 597

 

SharePoint 2007 supported only the Records Center site template for records management, and did not provide support for records management for individual libraries on non-Records Center sites. The fact that SharePoint 2010 now has this in-place capability does not do away with the need for the Records Center site template. You would continue to choose the Records Center template for the following scenarios:

  • A centralized approach to records management is preferred to simplify auditing and reporting tasks.
  • The need exists to perform records management on entities other than document library members, such as email messages or SharePoint list items.
  • The need exists to organize archived material without requiring human intervention on submitted items.

Organizing Content

When using the centralized approach of the Records Center site, it is likely that multiple libraries will be needed for archiving records, particularly in a case that will include many thousands of documents. There are three particular problems that must be overcome in such a case:

  • Thousands of documents must be routed to the proper library to support a well-organized site, but the routing must be carried out without the burden of human intervention.
  • Users must be blocked from ignoring the routing mechanism and choosing their own destination libraries.
  • The archive site must be organized in such a way that folder content does not exceed recommended maximum capacities.

The Content Organizer feature, which is automatically enabled for Records Center sites, is designed to address these very challenges. The Content Organizer creates a special library named the Drop Off Library. This library is the central location for submitting documents to the Records Center site. Documents submitted to this library are routed to another library based on defined rules. When you author these rules you specify the following:

  • One or more conditions to determine if a submitted document matches the rule.
  • A destination library where matching documents are routed.
  • A priority value, to indicate which rule should be applied in a case where more than one rule matches a document.

If a document is submitted that does not match a rule then the submitter and the owner of the site are notified. In addition, the document remains in the Drop Off Library until the site owner intervenes with a new rule.

In addition to applying rules for routing, the Content Organizer feature also provides the Folder Partitioning capability. Folder Partitioning provides an automatic mechanism to ensure that folders do not contain an excessive number of items by automatically subdividing a folder once it reaches a certain threshold.

While you can create your own destination libraries in the Records Center site, there is a library already created for you named Record Library. The significance of this library is shown in Figure 1: Documents added to this library will automatically be declared as records.

RecordManagementinSharePoint2010img1

Figure 1. The Record Library automatically declares a document as a record.

In Place Records Management permits a user to manually indicate that a document is a record and subject to records management rules. In the case of the Record Library, the declaration is automatic: simply placing a document in this library implicitly declares that it is a record.

Managing the Records Center

While all of the settings for the Records Center site may be configured via the Site Settings page, the Records Center site template includes a dedicated page (see image below) for convenient access to site management tasks such as defining rules, organizing libraries, and generating reports.
RecordManagementinSharePoint2010img2

The Records Center Management page provides
convenient access to standard configuration tasks.

John.UnderwoodThis post is an excerpt from the online courseware for our Microsoft SharePoint 2010: Enterprise Content Management course written by expert John Underwood.

John Underwood is a technical evangelist for a SharePoint consulting company, with 30 years of programming experience, including 20 years on the Microsoft platform and 10 years with .NET. John also has extensive experience using, configuring, and programming SharePoint.

 

 

Roots of SQL Server Data Tools

Thumbnail for 580Microsoft has long supported application database development with features built into Visual Studio, ranging from support for data access to the ability to create a connection to a database and manipulate database objects and data in simple ways. Various add-ons over the years have expanded those basic abilities, but even developers were constantly having to bounce between Visual Studio and either Enterprise Manager (in earlier versions of SQL Server) or Management Studio (in more recent versions, including SQL Server 2012) to perform data-related tasks, such as to create database tables, set security features, or execute stored procedures. Neither Visual Studio nor the SQL Server tools fully supported database development.

Then several years ago, Microsoft released its first version of the Team System Edition of Visual Studio 2008. This was a huge package of group software collaboration tools, including a long overdue successor to its Visual Source Safe source code control product. Over time, Team System spawned Architecture, Testing, and Development editions. But for a long time, one piece was missing: a database edition.

Microsoft soon rectified that, and released the product code named Data Dude. Officially, it is Visual Studio 2008 Team System Database Edition. Definitely a case where the code name was way cooler than the official name!

Data Dude, er, Database Edition, was a set of tools for managing the full database development lifecycle. Software developers were intimately familiar with the process, since it mirrors the code, build, deploy, rinse, repeat cycle common in software development. (And it can handle agile development methodologies as well.) Database administrators had to get used to some things, but could most certainly be part of the process.

Microsoft had several important high-level goals for the product:

  • Provide integrated change management, just like source control systems. This lets you go back in time to earlier versions of the database project and also provides controlled access to the project components to various developers for collaborative, simultaneous development.
  •  Manage database projects by allowing you to monitor progress and perform code reviews.
  •  Find and understand differences between versions. This way you can easily find the differences that cause problems in order to resolve them quickly.
  •  Make changes and see their effectiveness, without necessarily needing to build an entire project.
  • Support isolated development environments, so that each developer can work on their part of the project and test the changes before checking them in and distributing them to the rest of the team.
  • Test solutions to validate the design and code. You can use Team System’s support for unit tests to make sure that the design, code, and data doesn’t introduce any breaking changes.
  • Simplify deployment, of both the entire database and changes. This supports a variety of deployment scenarios during development and after the database goes into production, including finding the changes made to a test version of the database relative to a production version of the database.
  • Facilitate collaborative development of databases, so that team
    members can work together productively.

Database Edition was a huge step forward to make the process of creating database projects similar to creating application projects, particularly with its collaboration tools, support for source control, and test integration. But even with this step, things just weren’t as deeply integrated as they could be, in three primary ways:

Developer Edition wasn’t fully integrated with the database server. It enabled developers to perform more database-specific actions than earlier tools, but you still had to pop over to Management Studio too often.

  • Database developers had one tool to create database objects, and another tool—the Business Intelligence Development Studio
  • (BIDS)—for BI projects, adding a significant third tool to the mix in addition to Visual Studio and Management Studio.
  • Developer Edition made many simple things very easy, but once you went past simple stuff things got very hard. This is a rather subjectiv assessment, we realize, but there just seemed to be too many work arounds for what should have been easy.

The Database Edition was a great set of tools, particularly relative to what came before it. But with SQL Server 2012, Microsoft introduced what has so far proven to be the best set of tools yet, truly integrating database development tools into Visual Studio 2010 and 2012.

ldn-expertdkielyThis post is an excerpt from the online courseware for our SQL Server 2012: Advanced SQL CLR course written by expert Don Kiely. 

Don Kiely is a featured instructor on many of our SQL Server and Visual Studio courses. He is a nationally recognized author, instructor and consultant who travels the country sharing his expertise in SQL Server and security.

Generic Lists in LINQ

LINQ allows you to query over any type of generic list. The most common list type you’ll use is List, but LINQ allows you to work with any of the following list types, in the System.Collections.Generic namespace unless otherwise specified:

  • List<T>
  • LinkedList<T>
  • Queue<T>
  • Stack<T>
  • HashSet<T>
  • System.Collections.ObjectModel.Collection<T>
  • System.ComponentModel.BindingList<T>

Just to prove the point, the sample project includes the QueryGenericList method. This method performs similar work to the earlier QueryArray method, this time showing both query syntax, and functional syntax. Listing 2 shows the entire procedure.


Listing 2. The QueryGenericList method shows off several different techniques, including query vs. functional syntax.

Running this procedure displays the output shown in the Figure below.

The Figure above. The QueryGenericList procedure provides a list of files.

The QueryGenericList procedure starts by retrieving the array of files, and copying the data into a generic list:

Next, the code uses standard query syntax to retrieve from the list all the files whose length is less than 1000 bytes, ordered first by length in descending order, and then for files with matching lengths, by file name. The query retrieves an anonymous type containing the Name and Length properties of the file:

Finally, the procedure demonstrates the equivalent query, created using function syntax instead. This query returns the same data in the same order, but does it by calling extension methods with lambda expressions defining their behavior:

Note a few things about this query definition:

  • The Where function accepts a lambda expression that returns true or false for each item in the collection. Items for which the lambda expression returns false are excluded from the collection:
  • The OrderByDescending method (and its “cousin,” the OrderBy method) accepts a lambda expression that returns information indicating how to sort the data. In this case, the sorting occurs based on the Length property of each FileInfo object:
  • Using the standard query syntax, you can indicate ordering by multiple columns by simply including the columns separated with a comma. In function syntax, you must use the ThenBy or ThenByDescending method to indicate a secondary sort. As a parameter to the method, pass a lambda expression which, again, indicates the sort order. In this case, the secondary sort uses the Name property of the input FileInfo object:
  • The Select method accepts a lambda expression that identifies which field or fields you want the query to return. In this case, the query returns an anonymous type containing the Name and Length properties 

NOTE Remember, all the techniques you’ve seen in this example apply to any type of LINQ query, not just LINQ to Objects, and not just queries that work with generic lists.

TIP: The System.Linq.Enumerable class provides a large number of extension methods that add behavior to queryable objects, much like the Select, Where, OrderBy, ThenBy, OfType, and other methods you’ve already seen. Later sections in this chapter introduce many of these methods. For more information, review the Microsoft documentation for the System.Linq.Enumerable class and its many methods.

 

ldn-expertkgetzThis post is an excerpt from the online courseware for our Microsoft LINQ Using Visual C# 2010 course written by expert Ken Getz.

Ken Getz is a Visual Studio expert with over 25 years of experience as a successful developer and consultant. He is a nationally recognized author and speaker, as well as a featured instructor for LearnNowOnline.

Taking a Deeper Look at New Changes in the SharePoint Platform

en-usRecently, we talked about the new changes to Microsoft SharePoint and how that’s creating demand for experts in this wildly popular platform. Today we’d like to briefly look at some of these changes, many of which have been summarized by Mark Kashman, a SharePoint senior product manager, here.

(In fact, for those looking for SharePoint related work, the aforementioned article is a must-read. That and our SharePoint tutorial, of course.)

OK, so about those changes.

For starters, SharePoint will be integrated with Yammer, a social media application. The user interface, meanwhile, will include touch capabilities and asynchronous calls. Subscribers can share documents and files to users both inside and outside their company with a new “Guest Link” feature. And new “on-hover” feature lets users view contact information or a document preview for a document search.

This is all, of course, the tip of the iceberg. And it’s precisely because of that – new capabilities, new functionality, new complexity – that companies all over will be looking for SharePoint ninjas.

7f6b1efb-94c0-4c58-b924-1d9cf41c59dc

 

 

Thousands of developers worldwide use LearnNowOnline to gain the technical skills they need to succeed on the job and advance their career.