The mysteries of software development and networking... RSS 2.0



 Friday, May 09, 2008

Okay, so you read the title of this post. Perhaps you're expecting huge amounts of code, but guess what. As it turns out, this is so ridiculously easy. This will be a very short post.

Step one is to have a method that loads an RSS feed. WCF offers a new class called SyndicationFeed.

private SyndicationFeed Load( string url )

{

  XmlReader reader = XmlReader.Create( url );

  SyndicationFeed feed = SyndicationFeed.Load( reader );

  return feed;

}

 

The above method will take a url and use to load a feed. Now suppose I have a list of urls and I want to take all the items in all the feeds, sort them and use them to generate a new, aggregated feed. Sounds like a fair amount of work, right.

Here is the code:

 

private SyndicationFeed Aggregate( List<string> urls )

{

  var items = from url in urls

              from item in Load( url ).Items

              orderby item.PublishDate descending

              select item;

 

  SyndicationFeed feed = new SyndicationFeed( items );

  return feed;

}

 

Cool!

Friday, May 09, 2008 11:10:19 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ | WCF
 Monday, April 21, 2008

The Maine Developer Network is hosting a Geek Lunch tomorrow at the State of Maine, Harlow Building at 18 Elkins Ave in Augusta.
Chris Bowen will be presenting on LINQ & Language Improvements in C# 3.0/VB 9.
Sign up here.

LINQ (Language Integrated Query) is a unified approach for querying data using coding syntax that remains consistent regardless of the data source. It WILL change the way you work as a developer and architect and this session will help you on your way to using it effectively. To understand how LINQ works, we'll first navigate the new features of C# 3.0 and VB 9.0 that enable LINQ functionality. Then, we'll dive into .NET 3.5 and Visual Studio 2008 to explore the various realms of LINQ: Datasets, XML, Database/SQL, in-memory objects, and more. By the end of this session, you'll have a solid understanding of how LINQ works and what it can do for your applications.

Monday, April 21, 2008 8:50:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | LINQ
 Thursday, March 27, 2008

Since I was looking at books today anyway I thought I'd research what is available C# 3.0, I haven't read any of these yet, but check them out:

Thursday, March 27, 2008 12:34:28 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ
 Monday, March 24, 2008

The 22nd of April the Maine Developer Network is organizing a Geek Lunch. We'll be meeting at the State of Maine offices in Augusta to listen to Chris Bowen present on LINQ & Language Improvements in C# 3.0/VB 9.

Pizza will be provided and attendance is free and open for everyone!

More info and RSVP here.

Monday, March 24, 2008 11:52:01 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | LINQ
 Sunday, November 11, 2007

Earlier this year the C# team implemented a change in the design of anonymous types. It used to be possibly to create an anonymous type and then change a property on the anonymous type. The code would look like this:

var x = new { Name = "Mark", Age = 0 };
x.Age = 35;

In Visual Studio 2008 beta 2 this is however no longer possible since anonymous types are now immutable. There are apparently good reasons for doing this and Sree explains it in this post and there is an issue on MSConnect where Mads from the C# team explains the reasoning. Must say I don't completely get the reasoning, especially since VB.NET does not have this restriction.

Sunday, November 11, 2007 11:23:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ

The website www.hookedonlinq.com has an excellent article explaining the basics of LINQ to SQL. It's called LINQ to SQL - 5 minute overview.

Sunday, November 11, 2007 10:47:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ

If you want to join data which is in a list with data that is in the database, then you need to use the 'Contains' operation.

The code below shows that we have a list containing two values, next we want to join this list with some data in the database. This data has an Id and an Description.
You might be tempted to use the join operator, but that will fail, instead, call the Contains() method.

static void Main(string[] args)
{
    List<int> l = new List<int>();
    l.Add(1);
    l.Add(2);

    CustomerInfoDBDataContext db = new CustomerInfoDBDataContext();
    var result = from pi in db.PersonalInfos
                 where l.Contains(pi.Id)
                 select pi.Id + " - " + pi.Description;

    foreach (var info in result)
    {
        Console.WriteLine(info);
    }
    Console.ReadLine();
}

Sunday, November 11, 2007 10:39:03 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ

Niels confirmed it for me. Yes, it is possible to run a LINQ to SQL query in SQL Server 2008 using a .NET managed stored procedure.

As he puts it: "yes you can - but as soon there are any transactions invloved things will go pear-shaped".

Note that there will also be an optimized LINQ to SQL provider as part of SQL Server 2008:

"Language Integrated Query (LINQ) enables developers to issue queries against data by using a managed programming language such as C# or Visual Basic.NET, instead of SQL statements. LINQ enables seamless, strongly typed, set-oriented queries written in .NET Framework languages to run against ADO.NET (LINQ to SQL), ADO.NET DataSets (LINQ to DataSets), the ADO.NET Entity Framework (LINQ to Entities), and to the Entity Data Service Mapping Provider. SQL Server 2008 features a new LINQ to SQL Provider that enables developers to use LINQ directly on SQL Server 2008 tables and columns."

Sunday, November 11, 2007 8:01:04 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ | SQL

Yesterday I spoke at the iSDC and Ronua Community Workshop. We had a great day and it was a pleasure meeting the people at iSDC, meeting the developers in Cluj and surroundings (some drove over 200km to make it to the meeting) and Petru Jucovschi (the DPE for Microsoft Romania).

Here are the two presentations that I did:

11-09-2007 - Developing Windows Vista gadgets.pptx (431.43 KB)

11-10-2007 - 2008.NET.pptx (252.91 KB)

In the Visual Studio 2008 presentation I also talked about the work I've done for AOL. The AOL developer site can be found at http://dev.aol.com and for more reference material on Vista gadgets you can visit my AOL blog.

Sunday, November 11, 2007 3:32:20 AM (Eastern Standard Time, UTC-05:00)  #    Comments [2] -
C# | General | LINQ | Vista | WCF

During my session yesterday at the iSDC and RONUA Community Workshop I received a question on how to do a group by together with calculating the sum of the group.

I couldn't remember the right syntax and had to go and look it up. There is actually a sample included on the 101 Linq Samples page (thanks Dragos!).

The query looks like this:

public void Linq80() {
   List products =
GetProductList();

   var categories =
      from p in products
      group p by p.Category into g
      select new {Category = g.Key, TotalUnitsInStock = g.Group.Sum(p => p.UnitsInStock)};

   ObjectDumper.Write(categories);
}

Sunday, November 11, 2007 3:14:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ
 Thursday, January 19, 2006

Follow this link to view the recent episode of MSDN TV where they discuss LINQ for VB.NET.

Overview
Visual Basic 9.0 will offer radical improvements in its ability to work with data in all its forms: as objects, as XML, and as relational data. Paul Vick and Amanda Silver discuss the latest Customer Tech Preview of the next version of Visual Basic to hit the Web. It includes support for DLinq (language integrated query over relational data) and expanded editor support for query statements and integrated XML.

Thursday, January 19, 2006 2:09:50 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ
 Saturday, January 14, 2006

Just a couple of links to stuff that's in beta right now:

WinFX, XAML and SDK
ASP.NET ATLAS
C# and LINQ
VB.NET and LINQ

Saturday, January 14, 2006 10:37:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.NET | C# | LINQ | WPF

I'm finally catching up on some reading that I've been meaning to do.

Right now I'm reading 'Programming Windows Presentation Foundation' by Chris Sells & Ian Griffiths. Good read and I hope to finish it on my next flight :-)

Also spend some time this morning reading an article by Ted Neward on MSDN (http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/linqcomparisons.asp) which gives food for thought on LINQ and the whole OR-mapping issue.

Saturday, January 14, 2006 10:13:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
LINQ | WPF
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 305
This Year: 49
This Month: 2
This Week: 1
Comments: 36
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)