Last active
December 17, 2015 20:19
-
-
Save bhameyie/5666809 to your computer and use it in GitHub Desktop.
Dynamic database wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a class wrapping the actual dynamic object | |
public class Database | |
{ | |
public static dynamic Open() | |
{ | |
return new DynamicDatatbase(); | |
} | |
public static dynamic Open(string connectionString, string providerName) | |
{ | |
return new DynamicDatatbase(connectionString,providerName); | |
} | |
} | |
public class DynamicDatatbase:DynamicObject | |
{ | |
public string ConnectionString { get; private set; } | |
public string ProviderName { get; private set; } | |
public DynamicDatatbase() | |
{ | |
} | |
public DynamicDatatbase(string connectionString, string providerName) | |
{ | |
ConnectionString = connectionString; | |
ProviderName = providerName; | |
} | |
public override bool TryGetMember(GetMemberBinder binder, out object result) | |
{ | |
var tableName = binder.Name; | |
result = new DynamicQueryBuilder(tableName); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment