Beispiel #1
0
        public string SelectAllSql()
        {
            TableMeta t = TableMeta.Get(typeof(T));
            TableMeta r = TableMeta.Get(typeof(R));

            return(Dialect.Actions.SelectAllJoinSql(new List <TableMeta>()
            {
                t, r
            }, new string[] { "t1", "t2" }));
        }
        public static AnonymousAdapter Open(string tableName)
        {
            TableMeta meta = TableMeta.Get(tableName);

            if (meta == null)
            {
                return(null);
            }

            return(new AnonymousAdapter(meta)
            {
                _tableName = meta.ParameterizedTableName
            });
        }
        public static TableAdapter <T> Open(params object[] args)
        {
            TableAdapter <T> adapter = Activator.CreateInstance <TableAdapter <T> >();

            if (typeof(IMash).IsAssignableFrom(typeof(T)))
            {
                adapter._isMultiTableJoin = true;
                return(adapter);
            }

            TableMeta meta = TableMeta.Get(typeof(T));

            if (meta is TableMetaInvalid)
            {
                throw new ArgumentException(typeof(T).FullName + " is invalid because " + string.Join(" and ", ((TableMetaInvalid)meta).Reasons.ToArray()));
            }

            if (args.Length != meta.TableParamCount)
            {
                throw new ArgumentException("Please specify " + meta.TableParamCount + " parameters");
            }

            string tableName = meta.CreateTableName(args);

            if (meta.CheckExists)
            {
                adapter.CreateTable(meta, tableName);
                // not a dynamicly created table, so don't need to check it exists now it's created
                meta.CheckExists = (meta.TableParamCount > 0);
            }

            adapter._meta      = meta;
            adapter._tableName = tableName;

            return(adapter);
        }