Filtering/Ordering Results

Back to Examples


When using the ToDataTable(), ToIEnumerable(), or ToList() methods for any View/Table Model you may have, the option of specifying additional clauses is available in MagnaDB. Just make sure to specify those additional clauses as arguments for any in these functions or their overloads.

Make sure you use the following parameters the way they're intended to:

using System;

namespace TestMagnaDB
{
    class Program
    {
        static void Main(string[] args)
        {
            const string Longhair = "Longhair";
            
            // Here's an example on how to order/filter results.
            // Let's say we have our Cat class (Home Page, Table Models section)
            // and we wanted only the kittens that were Longhair and we wanted
            // them ordered by name. The next line of code accomplishes that.
            var longhairKittensByName = Cat.ToList("WHERE Breed='{0}' ORDER BY Name", Longhair);
        }
    }
}