Writing custom LINQ provider

 

In this post, I will show  how to create a sample LINQ provider.Creating LINQ provider can be far more complex, but here I will demonstrate the very basic one to start.

This sample is done by using VS2008 Beta 2. I finished of this is post by creating a fictious Person query provider that in turn the gives a glimpse of creating custom LINQ provider for pulling data from source, in a more descriptive and convenient way, rather calling out boring GetBy methods.

Via Writing custom LINQ provider – Mehfuz’s WebLog

Windows Home Server Toolkit v1 – The Nuts and Bolts

 

As you’ve probably seen from Robert McLaws’ blog post, there’s a new Toolkit for Windows Home Server.  There are several components to this. Some run in the WHS Console as an Add-in, and others can be run locally on the client, or the server. 

The Console Add-in gives you a new item under Settings, labeled Toolkit.  From there you have 4 available tabs. Remote, Storage, Backup and Support. 

On the Server side of things………….

The Remote tab gives you access to tools to help with troubleshooting and configuration of the Remote Access web site.

whstoolkit_rmt

And more screenshots via Windows Home Server Toolkit v1 – The Nuts and Bolts

Linq to Xml – querying an RSS feed

 

Linq (and all its flavors) will come out with .Net 3.5 and Visual Studio 2008. Along with the Xml support are classes such as XDocument, XElement, XAttribute, etc. What’s interesting about XElement in particular is that it allows us to load some Xml from many sources and query into it. Depending on your experience with XPath, an Xml Linq query may be easier to write AND read.

Let’s look at a sample Linq to Xml query. I’m going to use my blog’s RSS feed, http://feeds.feedburner.com/jeffreypalermo.

Let’s start simple. We’ll read in the Xml from the RSS feed and enumerate through all the posts (or “items” in the RSS world).

XElement rssFeed = XElement.Load(@"http://feeds.feedburner.com/jeffreypalermo");

var items = from item in rssFeed.Elements("channel").Elements("item") 
   select item;

Console.WriteLine(items.Count());
foreach (object o in items){
 Console.WriteLine(o);}

Note that we are merely reading in the feed into an XElement and then selecting all item nodes from the document.

That’s pretty interesting that we can filter to only the “item” nodes that quickly, but what if I want to find the posts with the author of “Jeffrey Palermo” (never mind that this is my feed, but imagine it was a composite feed).

XNamespace dc = "http://purl.org/dc/elements/1.1/";

XElement rssFeed = XElement.Load(@"http://feeds.feedburner.com/jeffreypalermo");

var items = from item in rssFeed.Elements("channel").Elements("item")
 where item.Element(dc + "creator").Value == "Jeffrey Palermo"
 select item;

foreach (object o in items){
 Console.WriteLine(o); }

I gave this example to illustrate how to use the XNamespace class to help filter in nodes that declare a namespace prefix such as “dc:creator” in an RSS feed. Note the “where” clause in my Linq query.

And more like using XNamespace, creating transformation using Custom Type Collection with anonymous type, turn the anonymous type to a concrete type.

Linq to Xml – querying an RSS feed  Jeffrey Palermo

Setup SVN Local Repository – Step by Step

0. FAQ First

Q: I heard that Subversion is an Apache extension? Does this mean I have to set up Apache to use Subversion?

A: The short answer: no. The long answer: if you just want to access a repository, then you only need to build a Subversion client. If you want to host a networked repository, then you need to set up either Apache2 or an “svnserve” server.

for more faq: http://subversion.tigris.org/faq.html

1. Creating The Repository With TortoiseSVN image

  1. Open the windows explorer
  2. Create a new folder and name it e.g. SVNRepository
  3. Right-click on the newly created folder and select TortoiseSVN → Create Repository here….

A repository is then created inside the new folder. Don’t edit those files yourself!!!. If you get any errors make sure that the folder is empty and not write protected.

 

 

2. Local Access to the Repository

To access your local repository you need the path to that folder. Just remember that Subversion expects all repository paths in the form file:///C:/SVNRepository/. Note the use of forward slashes throughout.

To access a repository located on a network share you can either use drive mapping, or you can use the UNC path. For UNC paths, the form is file://ServerName/path/to/repos/. Note that there are only 2 leading slashes here.

3. Repository Layout

Before you import your data into the repository you should first think about how you want to organize your data. If you use one of the recommended layouts you will later have it much easier.

There are some standard, recommended ways to organize a repository. Most people create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies. If a repository holds only one project, then often people create these top-level directories:

/trunk

/branches

/tags

If a repository contains multiple projects, people often index their layout by branch:

/trunk/paint

/trunk/calc

/branches/paint

/branches/calc

/tags/paint

/tags/calc

…or by project:

/paint/trunk

/paint/branches

/paint/tags

/calc/trunk

/calc/branches

/calc/tags

Indexing by project makes sense if the projects are not closely related and each one is checked out individually. For related projects where you may want to check out all projects in one go, or where the projects are all tied together in a single distribution package, it is often better to index by branch. This way you have only one trunk to checkout, and the relationships between the sub-projects is more easily visible.

So if you haven’t already created a basic folder structure inside your repository you should do that now:

  1. create a new empty folder on your hard drive (NOT INSIDE THE Already created repository – SVNRepository)

  2. create your desired top-level folder structure inside that folder – don’t put any files in it yet!

  3. import this structure into the repository via a right click on the folder and selecting TortoiseSVN → Import… This will import your temp folder into the repository root to create the basic repository layout.

Note that the name of the folder you are importing does not appear in the repository, only its contents. For example, create the following folder structure:

C:\Temp\New\trunk
C:\Temp\New\branches
C:\Temp\New\tags

Import Layout C:\Temp\New into the repository root, which will then look like this:

/trunk
/branches
/tags

You can also use the repository browser to create new folders directly in the repository.

4. Import Content

Before you import your project into a repository you should:

  1. Remove all files which are not needed to build the project (temporary files, files which are generated by a compiler e.g. *.obj, compiled binaries, …)

  2. Organize the files in folders and subfolders. Although it is possible to rename/move files later it is highly recommended to get your project’s structure straight before importing!

imageNow select the top-level folder of your project directory structure in the windows explorer and right click to open the context menu. Select the command TortoiseSVN → Import which brings up a dialog box for you to enter the URL of the repository into which you want to import your project. 

As soon as you press OK TortoiseSVN imports the complete directory tree including all files into the repository. As before, the name of the folder you import does not appear in the repository, only the folder contents. The project is now stored in the repository under version control. Please note that the folder you imported is NOT under version control! To get a version-controlled working copy you need to do a Checkout of the version you just imported.

 

 

 

For more information, take a look at the TortoiseSVN Help Context Menu.