示例#1
0
        public virtual DbEntityProvider New(QueryPolicy policy)
        {
            var n = New(this.Connection, this.Mapping, policy);

            n.Log = this.Log;
            return(n);
        }
示例#2
0
        public static Expression Build(QueryLinguist linguist, QueryPolicy policy, Expression expression, Expression provider)
        {
            var executor = Expression.Parameter(typeof(QueryExecutor), "executor");
            var builder  = new ExecutionBuilder(linguist, policy, executor);

            builder.variables.Add(executor);
            builder.initializers.Add(Expression.Call(Expression.Convert(provider, typeof(ICreateExecutor)), "CreateExecutor", null, null));
            var result = builder.Build(expression);

            return(result);
        }
示例#3
0
 public EntityProvider(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     if (language == null)
     {
         throw new InvalidOperationException("Language not specified");
     }
     if (mapping == null)
     {
         throw new InvalidOperationException("Mapping not specified");
     }
     if (policy == null)
     {
         throw new InvalidOperationException("Policy not specified");
     }
     this.language = language;
     this.mapping  = mapping;
     this.policy   = policy;
     this.tables   = new Dictionary <MappingEntity, IEntityTable>();
 }
示例#4
0
        public static DbEntityProvider From(string provider, string connectionString, QueryMapping mapping, QueryPolicy policy)
        {
            if (provider == null)
            {
                var clower = connectionString.ToLower();
                // try sniffing connection to figure out provider
                if (clower.Contains(".mdb") || clower.Contains(".accdb"))
                {
                    provider = "IQToolkit.Data.Access";
                }
                else if (clower.Contains(".sdf"))
                {
                    provider = "IQToolkit.Data.SqlServerCe";
                }
                else if (clower.Contains(".sl3") || clower.Contains(".db3"))
                {
                    provider = "IQToolkit.Data.SQLite";
                }
                else if (clower.Contains(".mdf"))
                {
                    provider = "IQToolkit.Data.SqlClient";
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Query provider not specified and cannot be inferred."));
                }
            }

            Type providerType = GetProviderType(provider);

            if (providerType == null)
            {
                throw new InvalidOperationException(string.Format("Unable to find query provider '{0}'", provider));
            }

            return(From(providerType, connectionString, mapping, policy));
        }
示例#5
0
 public static DbEntityProvider From(string provider, string connectionString, string mappingId, QueryPolicy policy)
 {
     return(From(provider, connectionString, GetMapping(mappingId), policy));
 }
示例#6
0
 public static DbEntityProvider From(string connectionString, QueryMapping mapping, QueryPolicy policy)
 {
     return(From((string)null, connectionString, mapping, policy));
 }
示例#7
0
 public virtual DbEntityProvider New(DbConnection connection, QueryMapping mapping, QueryPolicy policy)
 {
     return((DbEntityProvider)Activator.CreateInstance(this.GetType(), new object[] { connection, mapping, policy }));
 }
示例#8
0
 public override DbEntityProvider New(DbConnection connection, QueryMapping mapping, QueryPolicy policy)
 {
     return(new SqlQueryProvider((SqlConnection)connection, mapping, policy));
 }
示例#9
0
 public SqlQueryProvider(SqlConnection connection, QueryMapping mapping, QueryPolicy policy)
     : base(connection, TSqlLanguage.Default, mapping, policy)
 {
 }
 private RelationshipIncluder(QueryMapper mapper)
 {
     this.mapper = mapper;
     this.policy = mapper.Translator.Police.Policy;
 }
 public QueryPolice(QueryPolicy policy, QueryTranslator translator)
 {
     this.policy     = policy;
     this.translator = translator;
 }
 public QueryTranslator(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     this.linguist = language.CreateLinguist(this);
     this.mapper   = mapping.CreateMapper(this);
     this.police   = policy.CreatePolice(this);
 }
示例#13
0
 public static Expression Rewrite(QueryPolicy policy, QueryLanguage language, Expression expression)
 {
     return(new ClientJoinedProjectionRewriter(policy, language).Visit(expression));
 }
示例#14
0
 private ClientJoinedProjectionRewriter(QueryPolicy policy, QueryLanguage language)
 {
     this.policy   = policy;
     this.language = language;
 }
示例#15
0
        public static DbEntityProvider From(Type providerType, string connectionString, QueryMapping mapping, QueryPolicy policy)
        {
            Type adoConnectionType = GetAdoConnectionType(providerType);

            if (adoConnectionType == null)
            {
                throw new InvalidOperationException(string.Format("Unable to deduce ADO provider for '{0}'", providerType.Name));
            }
            DbConnection connection = (DbConnection)Activator.CreateInstance(adoConnectionType);

            // is the connection string just a filename?
            if (!connectionString.Contains('='))
            {
                MethodInfo gcs = providerType.GetMethod("GetConnectionString", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string) }, null);
                if (gcs != null)
                {
                    var getConnectionString = (Func <string, string>)Delegate.CreateDelegate(typeof(Func <string, string>), gcs);
                    connectionString = getConnectionString(connectionString);
                }
            }

            connection.ConnectionString = connectionString;

            return((DbEntityProvider)Activator.CreateInstance(providerType, new object[] { connection, mapping, policy }));
        }
示例#16
0
 public DbEntityProvider(DbConnection connection, QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
     : base(language, mapping, policy)
 {
     if (connection == null)
     {
         throw new InvalidOperationException("Connection not specified");
     }
     this.connection = connection;
 }
示例#17
0
 private ExecutionBuilder(QueryLinguist linguist, QueryPolicy policy, Expression executor)
 {
     this.linguist = linguist;
     this.policy   = policy;
     this.executor = executor;
 }