Inheritance: IProviderSpecificMetadata
コード例 #1
0
ファイル: Cache.cs プロジェクト: BrewDawg/Tiraggo
        public static Dictionary<string, MySqlParameter> GetParameters(Guid dataID,
            tgProviderSpecificMetadata providerMetadata, tgColumnMetadataCollection columns)
        {
            lock (parameterCache)
            {
                if (!parameterCache.ContainsKey(dataID))
                {
                    // The Parameters for this Table haven't been cached yet, this is a one time operation
                    Dictionary<string, MySqlParameter> types = new Dictionary<string, MySqlParameter>();

                    MySqlParameter param1;
                    foreach (tgColumnMetadata col in columns)
                    {
                        tgTypeMap typeMap = providerMetadata.GetTypeMap(col.PropertyName);
                        if (typeMap != null)
                        {
                            string nativeType = typeMap.NativeType;
                            MySqlDbType dbType = Cache.NativeTypeToDbType(nativeType);

                            param1 = new MySqlParameter(Delimiters.Param + col.PropertyName, dbType, 0, col.Name);
                            param1.SourceColumn = col.Name;

                            switch (dbType)
                            {
                                case MySqlDbType.Decimal:
                                case MySqlDbType.NewDecimal:
                                case MySqlDbType.Double:
                                case MySqlDbType.Float:
                                case MySqlDbType.Int16:
                                case MySqlDbType.Int24:
                                case MySqlDbType.Int32:
                                case MySqlDbType.Int64:
                                case MySqlDbType.UInt16:
                                case MySqlDbType.UInt24:
                                case MySqlDbType.UInt32:
                                case MySqlDbType.UInt64:

                                    param1.Size = (int)col.CharacterMaxLength;
                                    param1.Precision = (byte)col.NumericPrecision;
                                    param1.Scale = (byte)col.NumericScale;
                                    break;

                                case MySqlDbType.String:
                                case MySqlDbType.VarString:
                                case MySqlDbType.VarChar:
                                    param1.Size = (int)col.CharacterMaxLength;
                                    break;

                            }
                            types[col.Name] = param1;
                        }
                    }

                    parameterCache[dataID] = types;
                }
            }

            return parameterCache[dataID];
        }
コード例 #2
0
ファイル: Cache.cs プロジェクト: BrewDawg/Tiraggo
        public static Dictionary<string, SqlCeParameter> GetParameters(Guid dataID,
            tgProviderSpecificMetadata providerMetadata, tgColumnMetadataCollection columns)
        {
            lock (parameterCache)
            {
                if (!parameterCache.ContainsKey(dataID))
                {
                    // The Parameters for this Table haven't been cached yet, this is a one time operation
                    Dictionary<string, SqlCeParameter> types = new Dictionary<string, SqlCeParameter>();

                    SqlCeParameter param1;
                    foreach (tgColumnMetadata col in columns)
                    {
                        tgTypeMap typeMap = providerMetadata.GetTypeMap(col.PropertyName);
                        if (typeMap != null)
                        {
                            string nativeType = typeMap.NativeType;
                            SqlDbType dbType = Cache.NativeTypeToDbType(nativeType);

                            param1 = new SqlCeParameter(Delimiters.Param + col.PropertyName, dbType, 0, col.Name);
                            param1.SourceColumn = col.Name;

                            switch (dbType)
                            {
                                case SqlDbType.Decimal:

                                    param1.Precision = (byte)col.NumericPrecision;
                                    param1.Scale = (byte)col.NumericScale;
                                    break;

                                case SqlDbType.DateTime:

                                    param1.Precision = 23;
                                    param1.Scale = 3;
                                    break;

                                case SqlDbType.SmallDateTime:

                                    param1.Precision = 16;
                                    break;

                            }
                            types[col.Name] = param1;
                        }
                    }

                    parameterCache[dataID] = types;
                }
            }

            return parameterCache[dataID];
        }
コード例 #3
0
ファイル: Cache.cs プロジェクト: BrewDawg/Tiraggo
        public static Dictionary<string, VistaDBParameter> GetParameters(Guid dataID,
            tgProviderSpecificMetadata providerMetadata, tgColumnMetadataCollection columns)
        {
            lock (parameterCache)
            {
                if (!parameterCache.ContainsKey(dataID))
                {
                    // The Parameters for this Table haven't been cached yet, this is a one time operation
                    Dictionary<string, VistaDBParameter> types = new Dictionary<string, VistaDBParameter>();

                    VistaDBParameter param1;
                    foreach (tgColumnMetadata col in columns)
                    {
                        tgTypeMap typeMap = providerMetadata.GetTypeMap(col.PropertyName);
                        if (typeMap != null)
                        {
                            string nativeType = typeMap.NativeType;
                            VistaDBType dbType = Cache.NativeTypeToDbType(nativeType);

                            param1 = new VistaDBParameter(Delimiters.Param + col.PropertyName, dbType, 0, col.Name);
                            param1.SourceColumn = col.Name;

                            switch (dbType)
                            {
                                case VistaDBType.BigInt:
                                case VistaDBType.Int:
                                case VistaDBType.SmallInt:
                                case VistaDBType.Decimal:
                                case VistaDBType.Float:
                                case VistaDBType.Money:
                                case VistaDBType.SmallMoney:

                                    param1.Size = (int)col.CharacterMaxLength;
                                    break;

                            }
                            types[col.Name] = param1;
                        }
                    }

                    parameterCache[dataID] = types;
                }
            }

            return parameterCache[dataID];
        }
コード例 #4
0
        /// <summary>
        /// This initializes the tgDataRequest for the query.
        /// </summary>
        /// <param name="request">The request to populate.</param>
        protected void PopulateRequest(tgDataRequest request)
        {
            IMetadata meta = this.Meta;

            tgConnection conn = this.tg2.Connection;
            tgProviderSpecificMetadata providerMetadata = meta.GetProviderMetadata(conn.ProviderMetadataKey);

            IDynamicQuerySerializableInternal iQuery = this as IDynamicQuerySerializableInternal;

            if ((this.queries != null && this.queries.Count > 0) || iQuery.InternalSetOperations != null)
            {
                AssignProviderMetadata(this, new List <tgDynamicQuerySerializable>());
            }

            string catalog = conn.Catalog;
            string schema  = conn.Schema;

            iData.Catalog          = catalog;
            iData.Schema           = schema;
            iData.DataID           = meta.DataID;
            iData.ProviderMetadata = providerMetadata;
            iData.Columns          = meta.Columns;

            request.ConnectionString = conn.ConnectionString;
            request.CommandTimeout   = conn.CommandTimeout;
            request.QueryType        = tgQueryType.DynamicQuery;
            request.DynamicQuery     = this;
            request.DataID           = meta.DataID;
            request.ProviderMetadata = providerMetadata;

            request.Catalog = catalog;
            request.Schema  = schema;
            request.Columns = meta.Columns;

            if (this.m_selectAll)
            {
                _selectAll();
            }

            if (tg.QuerySource == null || tg.QuerySource.Length == 0)
            {
                tg.QuerySource = providerMetadata.Source;
            }
        }
コード例 #5
0
ファイル: Shared.cs プロジェクト: BrewDawg/Tiraggo
        public static string CreateFullName(tgProviderSpecificMetadata providerMetadata)
        {
            string name = String.Empty;

            name += Delimiters.TableOpen;
            name += providerMetadata.Destination;
            name += Delimiters.TableClose;

            return name;
        }
コード例 #6
0
ファイル: Shared.cs プロジェクト: BrewDawg/Tiraggo
 public static string CreateFullName(tgProviderSpecificMetadata providerMetadata)
 {
     return Delimiters.TableOpen + providerMetadata.Destination + Delimiters.TableClose;
 }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        private void AssignProviderMetadata(tgDynamicQuerySerializable query, List <tgDynamicQuerySerializable> beenThere)
        {
            if (beenThere.Contains(query))
            {
                return;
            }

            beenThere.Add(query);

            tgDynamicQuery theQuery = query as tgDynamicQuery;
            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (theQuery != null)
            {
                tgConnection conn = theQuery.tg2.Connection;

                if (iQuery.ProviderMetadata == null)
                {
                    tgProviderSpecificMetadata providerMetadata = theQuery.Meta.GetProviderMetadata(conn.ProviderMetadataKey);
                    iQuery.DataID           = theQuery.Meta.DataID;
                    iQuery.Columns          = theQuery.Meta.Columns;
                    iQuery.ProviderMetadata = providerMetadata;
                }

                iQuery.Catalog = conn.Catalog;
                iQuery.Schema  = conn.Schema;
            }

            // This code is for proxies as they are unable to work with column and provider metadata
            // until serialized back to the server
            if (iQuery.SelectAll)
            {
                foreach (tgColumnMetadata col in (tgColumnMetadataCollection)iQuery.Columns)
                {
                    tgQueryItem item = new tgQueryItem(this, col.Name, col.esType);
                    query.Select(item);
                }
            }
            else
            {
                List <tgQueryItem> columns = iQuery.SelectAllExcept;

                if (columns != null)
                {
                    foreach (tgColumnMetadata col in (tgColumnMetadataCollection)iQuery.Columns)
                    {
                        bool found = false;

                        for (int i = 0; i < columns.Count; i++)
                        {
                            if (col.Name == (string)columns[i])
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            continue;
                        }

                        tgExpression item = new tgQueryItem(this, col.Name, col.esType);
                        query.Select(item);
                    }
                }
            }

            foreach (tgDynamicQuerySerializable subQuery in iQuery.queries.Values)
            {
                AssignProviderMetadata(subQuery, beenThere);
            }

            if (iQuery.InternalSetOperations != null)
            {
                foreach (tgSetOperation setOperation in iQuery.InternalSetOperations)
                {
                    AssignProviderMetadata(setOperation.Query, beenThere);
                }
            }
        }