public static DynamicRepository RepositoryFor(string tableName) { var repo = new DynamicRepository(tableName); AssociationByConventions.ApplyProjection(repo); return(repo); }
public static DynamicRepository RepositoryFor(string tableName, string connectionString) { var repo = new DynamicRepository(new ConnectionProfile { ConnectionString = connectionString }, tableName); AssociationByConventions.ApplyProjection(repo, connectionString); return(repo); }
dynamic MethodMissing(dynamic callInfo) { var tableName = callInfo.Name; if (!AssociationByConventions.TableExists(tableName, connectionString)) { throw new AssociationByConventionsException("Table [" + tableName + "] doesn't exist."); } var repositoryProperty = tableName + "Repository"; callInfo.Instance.SetMember(repositoryProperty, AssociationByConventions.RepositoryFor(tableName, connectionString)); callInfo.Instance.SetMember( tableName, new DynamicFunction(() => callInfo.Instance.GetMember(repositoryProperty))); return(callInfo.Instance.GetMember(tableName)()); }