Question: I'm doing some interop and need to pass some GUID's. Is there a way to add a GUID attribute to an enum value and when it is marshalled it has the appropriate value?

Basically I'm trying to convert the code

```
#if !defined( STATIC_KSDATAFORMAT_SUBTYPE_PCM )
#define STATIC_KSDATAFORMAT_SUBTYPE_PCM\
    DEFINE_WAVEFORMATEX_GUID(WAVE_FORMAT_PCM)
DEFINE_GUIDSTRUCT("00000001-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_PCM);
#define KSDATAFORMAT_SUBTYPE_PCM DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_PCM)
#endif

```

(and several other similar ones)

and use them in an enum so I can specify the appropriate subtype format easily. Obviously I could probably just use a dictionary or some other similar method but I would like to make it as transparent as possible.

It would be nice to do something like

```
enum MyGuids : Guid
{
  Guid1 = GUID("...") or just "..."
}

```

I can use a class/struct instead

```
static class MyGuids
{
    public static Guid flag1 = new Guid("9ED54F84-A89D-4fcd-A854-44251E925F09");
}

```

But the only problem here is there is no way to relate the Guid in unmanaged structure to this class. It's specified as Guid and if I replaced it with MyGuids then it won't be a Guid any more. e.g., I lose type safety since any guid can end up in the field and not just the ones from MyGuid.

Any ideas?

Answer: 
You are getting this compiling error because you are trying to use an *OrderBy* extension method that is only defined in **MvcContrib** and not in System.Linq.

In order to fix it, you just need to use the following line:

```
using MvcContrib.Sorting;

```

And then you can use the *OrderBy* method as in your original code:

```
listOfRfidTags = listOfRfidTags.OrderBy(sort.Column, sort.Direction);

```

Although *itowlson* answer works, he just reimplements what the *OrderBy* extension method in *MvcContrib* already does (see [SortExtensions.cs](http://mvccontrib.codeplex.com/SourceControl/changeset/view/459484756843#src/MVCContrib/Sorting/SortExtensions.cs)).
The OrderBy extension method takes a delegate for getting the sort key, not a column and direction. So this line:

```
listOfRfidTags = listOfRfidTags.OrderBy(sort.Column, sort.Direction);

```

needs to look something like this:

```
listOfRfidTags = listOfRfidTags.OrderBy(r => r.SomeProperty);

```

(or OrderByDescending depending on the sort.Direction). The trouble is that SomeProperty can't be determined at compile time because you want it to come from sort.Column. This means that if you want to use LINQ then you'll probably need to use [Dynamic LINQ](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx) or Reflection to extract the property you want to sort on e.g.

```
PropertyInfo property = typeof(RfidTag).GetProperty(sort.Column);
listOfRfidTags = listOfRfidTags.OrderBy(r => property.GetValue(r));

```

However, since you are using LightSpeed as your ORM, you can bypass LINQ and use the core API, which *does* allow dynamic column names:

```
Order order = Order.By(sort.Column);
if (sort.Direction == SortDirection.Descending))
  order = order.Descending();
IList<RfidTag> listOfRfidTags = uow.Find<RfidTag>(new Query { Order = order });

```

This has the side benefit that the sorting will happen on the database instead of in the Web application.