CoreSystem.Dynamic

  • Donymous: Dynamic expandable object that can initialize from DbDataReader or any other object.
Database db = DbFactory.GetDatabase("MyConnectionString");
List<Donymous> orders = db.ExecuteToDonymous("SELET * From dbo.Orders");

// Listing shipping addresses
foreach (var order in orders)
{
    Console.WriteLine(order["ShipAddress"]);

    // Arbitrary property at runtime
    order["IsNearAirport"] = order["ShipAddress"].ToString().Contains("Airport");
}

// Listing all shipping address via property
foreach (dynamic order in orders)
{
    Console.WriteLine(order.ShipAddress);

    // Arbitrary property at runtime
    order.IsNearAirport = order.ShipAddress.Contains("Airport");
}
However name indexer is much faster as compare to accessing via dynamic object property.

Last edited Sep 22, 2012 at 9:42 PM by farazmasoodkhan, version 1

Comments

No comments yet.