X Tutup
#region License // The PostgreSQL License // // Copyright (C) 2017 The Npgsql Development Team // // Permission to use, copy, modify, and distribute this software and its // documentation for any purpose, without fee, and without a written // agreement is hereby granted, provided that the above copyright notice // and this paragraph and the following two paragraphs appear in all copies. // // IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY // FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS // DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // // THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS // ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #endregion using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Npgsql.NameTranslation; using NpgsqlTypes; namespace Npgsql.TypeMapping { /// /// A type mapper, managing how to read and write CLR values to PostgreSQL data types. /// A type mapper exists for each connection, as well as a single global type mapper /// (accessible via /// /// /// public interface INpgsqlTypeMapper { /// /// Adds a new type mapping to this mapper, overwriting any existing mapping in the process. /// INpgsqlTypeMapper AddMapping(NpgsqlTypeMapping mapping); /// /// Removes an existing mapping from this mapper. Attempts to read or write this type /// after removal will result in an exception. /// bool RemoveMapping(string pgTypeName); /// /// Enumerates all mappings currently set up on this type mapper. /// IEnumerable Mappings { get; } /// /// Maps a CLR enum to a PostgreSQL enum type. /// /// /// CLR enum labels are mapped by name to PostgreSQL enum labels. /// The translation strategy can be controlled by the parameter, /// which defaults to . /// You can also use the on your enum fields to manually specify a PostgreSQL enum label. /// If there is a discrepancy between the .NET and database labels while an enum is read or written, /// an exception will be raised. /// /// /// A PostgreSQL type name for the corresponding enum type in the database. /// If null, the name translator given in will be used. /// /// /// A component which will be used to translate CLR names (e.g. SomeClass) into database names (e.g. some_class). /// Defaults to /// /// The .NET enum type to be mapped INpgsqlTypeMapper MapEnum(string pgName = null, INpgsqlNameTranslator nameTranslator = null) where TEnum : struct; /// /// Removes an existing enum mapping. /// /// /// A PostgreSQL type name for the corresponding enum type in the database. /// If null, the name translator given in will be used. /// /// /// A component which will be used to translate CLR names (e.g. SomeClass) into database names (e.g. some_class). /// Defaults to /// bool UnmapEnum(string pgName = null, INpgsqlNameTranslator nameTranslator = null) where TEnum : struct; /// /// Maps a CLR type to a PostgreSQL composite type. /// /// /// CLR fields and properties by string to PostgreSQL enum labels. /// The translation strategy can be controlled by the parameter, /// which defaults to . /// You can also use the on your members to manually specify a PostgreSQL enum label. /// If there is a discrepancy between the .NET and database labels while a composite is read or written, /// an exception will be raised. /// /// /// A PostgreSQL type name for the corresponding enum type in the database. /// If null, the name translator given in will be used. /// /// /// A component which will be used to translate CLR names (e.g. SomeClass) into database names (e.g. some_class). /// Defaults to /// /// The .NET type to be mapped INpgsqlTypeMapper MapComposite(string pgName = null, INpgsqlNameTranslator nameTranslator = null) where T : new(); /// /// Removes an existing enum mapping. /// /// /// A PostgreSQL type name for the corresponding composite type in the database. /// If null, the name translator given in will be used. /// /// /// A component which will be used to translate CLR names (e.g. SomeClass) into database names (e.g. some_class). /// Defaults to /// bool UnmapComposite(string pgName = null, INpgsqlNameTranslator nameTranslator = null) where T : new(); /// /// Resets all mapping changes performed on this type mapper and reverts it to its original, starting state. /// void Reset(); } }
X Tutup