コード例 #1
0
ファイル: DynamicDb.cs プロジェクト: shaurya947/Loam
        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)());
        }