Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -2,7 +2,7 @@ thisdir = tools/sqlmetal
SUBDIRS =
include ../../build/rules.make
dbmetal_src = ../../class/System.Data.Linq/src/DbMetal
dbmetal_src = src/DbMetal
ns = DbMetal.Language
LOCAL_MCS_FLAGS = \
@@ -13,12 +13,13 @@ LOCAL_MCS_FLAGS = \
-resource:$(dbmetal_src)/Language/GermanWords.txt,$(ns).GermanWords.txt \
-publicsign
LIB_REFS = System.Configuration System.Core System.Data System.Data.Linq System.Xml System
LIB_REFS = System.Configuration System.Core System.Data System.Xml System System.Runtime.Serialization
SQLMETAL_RESOURCES = \
$(dbmetal_src)/Language/EnglishWords.txt \
$(dbmetal_src)/Language/FrenchWords.txt \
$(dbmetal_src)/Language/GermanWords.txt
$(dbmetal_src)/Language/GermanWords.txt \
$(dbmetal_src)/../DbLinq.snk
EXTRA_DISTFILES = \
$(SQLMETAL_RESOURCES)
@@ -28,4 +29,3 @@ PROGRAM = sqlmetal.exe
$(PROGRAM) : Makefile $(SQLMETAL_RESOURCES)
include ../../build/executable.make

View File

@@ -1,40 +1,363 @@
AssemblyInfo.cs
../../class/System.Data.Linq/src/DbLinq.ProductInfo.cs
../../class/System.Data.Linq/src/DbMetal/AbstractParameters.cs
../../class/System.Data.Linq/src/DbMetal/Configuration/ProvidersSection.cs
../../class/System.Data.Linq/src/DbMetal/Generator/AttributeDefinition.cs
../../class/System.Data.Linq/src/DbMetal/Generator/CodeDomGenerator.cs
../../class/System.Data.Linq/src/DbMetal/Generator/CodeWriter.cs
../../class/System.Data.Linq/src/DbMetal/Generator/EntityInterface/IImplementation.cs
../../class/System.Data.Linq/src/DbMetal/Generator/EntityInterface/Implementation/IModifiedImplementation.cs
../../class/System.Data.Linq/src/DbMetal/Generator/EntityInterface/Implementation/INotifyPropertyChangedImplementation.cs
../../class/System.Data.Linq/src/DbMetal/Generator/EntityInterface/Implementation/INotifyPropertyChangingImplementation.cs
../../class/System.Data.Linq/src/DbMetal/Generator/EntityInterface/Implementation/InterfaceImplementation.cs
../../class/System.Data.Linq/src/DbMetal/Generator/GenerationContext.cs
../../class/System.Data.Linq/src/DbMetal/Generator/ICodeGenerator.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Context.Ctor.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Procedure.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CSCodeGenerator.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/CodeTextGenerator/CSCodeWriter.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/Processor.cs
../../class/System.Data.Linq/src/DbMetal/Generator/Implementation/SchemaLoaderFactory.cs
../../class/System.Data.Linq/src/DbMetal/Generator/IProcessor.cs
../../class/System.Data.Linq/src/DbMetal/Generator/ISchemaLoaderFactory.cs
../../class/System.Data.Linq/src/DbMetal/Generator/ParameterDefinition.cs
../../class/System.Data.Linq/src/DbMetal/Generator/SpecificationDefinition.cs
../../class/System.Data.Linq/src/DbMetal/Language/EnglishWords.cs
../../class/System.Data.Linq/src/DbMetal/Language/FrenchWords.cs
../../class/System.Data.Linq/src/DbMetal/Language/GermanWords.cs
../../class/System.Data.Linq/src/DbMetal/Mono/Options.cs
../../class/System.Data.Linq/src/DbMetal/Parameters.cs
../../class/System.Data.Linq/src/DbMetal/Program.cs
../../class/System.Data.Linq/src/DbMetal/Properties/Settings.Designer.cs
../../class/System.Data.Linq/src/DbMetal/Reference.cs
../../class/System.Data.Linq/src/DbMetal/Schema/DbmlRename.cs
../../class/System.Data.Linq/src/DbMetal/Schema/DbmlRenameLoader.cs
../../class/System.Data.Linq/src/DbMetal/Schema/NameAliasesLoader.cs
../../class/System.Data.Linq/src/DbMetal/Schema/TableAlias.cs
../../class/System.Data.Linq/src/DbMetal/Utility/EnvironmentExtension.cs
../../class/System.Data.Linq/src/DbMetal/Utility/VariablesExtension.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
../../build/common/MonoTODOAttribute.cs
src/DbLinq.Firebird/FirebirdDataContext.cs
src/DbLinq.Firebird/FirebirdExpressionTranslator.cs
src/DbLinq.Firebird/FirebirdSchemaLoader.Columns.cs
src/DbLinq.Firebird/FirebirdSchemaLoader.Constraints.cs
src/DbLinq.Firebird/FirebirdSchemaLoader.cs
src/DbLinq.Firebird/FirebirdSchemaLoader.StoredProcedures.cs
src/DbLinq.Firebird/FirebirdSchemaLoader.Tables.cs
src/DbLinq.Firebird/FirebirdSqlProvider.cs
src/DbLinq.Firebird/FirebirdVendor.cs
src/DbLinq.Ingres/IngresDataContext.cs
src/DbLinq.Ingres/IngresSchemaLoader.Columns.cs
src/DbLinq.Ingres/IngresSchemaLoader.Constraints.cs
src/DbLinq.Ingres/IngresSchemaLoader.cs
src/DbLinq.Ingres/IngresSchemaLoader.StoredProcedures.cs
src/DbLinq.Ingres/IngresSchemaLoader.Tables.cs
src/DbLinq.Ingres/IngresSqlProvider.cs
src/DbLinq.Ingres/IngresVendor.cs
src/DbLinq.MySql/MySqlDataContext.cs
src/DbLinq.MySql/MySqlSchemaLoader.Columns.cs
src/DbLinq.MySql/MySqlSchemaLoader.Constraints.cs
src/DbLinq.MySql/MySqlSchemaLoader.cs
src/DbLinq.MySql/MySqlSchemaLoader.StoredProcedures.cs
src/DbLinq.MySql/MySqlSchemaLoader.Tables.cs
src/DbLinq.MySql/MySqlSqlProvider.cs
src/DbLinq.MySql/MySqlVendor.cs
src/DbLinq.Oracle/OracleDataContext.cs
src/DbLinq.Oracle/OracleSchemaLoader.Columns.cs
src/DbLinq.Oracle/OracleSchemaLoader.Constraints.cs
src/DbLinq.Oracle/OracleSchemaLoader.cs
src/DbLinq.Oracle/OracleSchemaLoader.StoredProcedures.cs
src/DbLinq.Oracle/OracleSchemaLoader.Tables.cs
src/DbLinq.Oracle/OracleSqlProvider.cs
src/DbLinq.Oracle/OracleVendor.cs
src/DbLinq.PostgreSql/PgsqlDataContext.cs
src/DbLinq.PostgreSql/PgsqlSchemaLoader.Columns.cs
src/DbLinq.PostgreSql/PgsqlSchemaLoader.Constraints.cs
src/DbLinq.PostgreSql/PgsqlSchemaLoader.cs
src/DbLinq.PostgreSql/PgsqlSchemaLoader.StoredProcedures.cs
src/DbLinq.PostgreSql/PgsqlSchemaLoader.Tables.cs
src/DbLinq.PostgreSql/PgsqlSqlProvider.cs
src/DbLinq.PostgreSql/PgsqlVendor.cs
src/DbLinq.Sqlite/Schema/DataCommand.cs
src/DbLinq.Sqlite/SqliteDataContext.cs
src/DbLinq.Sqlite/SqliteSchemaLoader.Columns.cs
src/DbLinq.Sqlite/SqliteSchemaLoader.Constraints.cs
src/DbLinq.Sqlite/SqliteSchemaLoader.cs
src/DbLinq.Sqlite/SqliteSchemaLoader.Tables.cs
src/DbLinq.Sqlite/SqliteSqlProvider.cs
src/DbLinq.Sqlite/SqliteVendor.cs
src/DbLinq.SqlServer/SqlServerDataContext.cs
src/DbLinq.SqlServer/SqlServerExpressionTranslator.cs
src/DbLinq.SqlServer/SqlServerSchemaLoader.cs
src/DbLinq.SqlServer/SqlServerSqlProvider.cs
src/DbLinq.SqlServer/SqlServerTypeConversions.cs
src/DbLinq.SqlServer/SqlServerVendor.cs
src/DbLinq/Data/Linq/ChangeAction.cs
src/DbLinq/Data/Linq/ChangeSet.cs
src/DbLinq/Data/Linq/Database/IDatabaseContext.cs
src/DbLinq/Data/Linq/Database/IDatabaseTransaction.cs
src/DbLinq/Data/Linq/Database/Implementation/DatabaseConnection.cs
src/DbLinq/Data/Linq/Database/Implementation/DatabaseContext.cs
src/DbLinq/Data/Linq/Database/Implementation/DatabaseTransaction.cs
src/DbLinq/Data/Linq/Database/Implementation/TransactionalCommand.cs
src/DbLinq/Data/Linq/Database/ITransactionalCommand.cs
src/DbLinq/Data/Linq/DataContext.cs
src/DbLinq/Data/Linq/DataLoadOptions.cs
src/DbLinq/Data/Linq/DBLinqExtendedAttributte.cs
src/DbLinq/Data/Linq/EntityRef.cs
src/DbLinq/Data/Linq/EntitySet.cs
src/DbLinq/Data/Linq/Identity/IdentityKey.cs
src/DbLinq/Data/Linq/Identity/IIdentityProvider.cs
src/DbLinq/Data/Linq/Identity/IIdentityReader.cs
src/DbLinq/Data/Linq/Identity/IIdentityReaderFactory.cs
src/DbLinq/Data/Linq/Identity/Implementation/IdentityProviderReader.cs
src/DbLinq/Data/Linq/Identity/Implementation/IdentityReader.cs
src/DbLinq/Data/Linq/Identity/Implementation/IdentityReaderFactory.cs
src/DbLinq/Data/Linq/IExecuteResult.cs
src/DbLinq/Data/Linq/IMemberModificationHandler.cs
src/DbLinq/Data/Linq/Implementation/DisabledEntityTracker.cs
src/DbLinq/Data/Linq/Implementation/EntityState.cs
src/DbLinq/Data/Linq/Implementation/EntityTrack.cs
src/DbLinq/Data/Linq/Implementation/EntityTracker.cs
src/DbLinq/Data/Linq/Implementation/IEntityTracker.cs
src/DbLinq/Data/Linq/Implementation/MemberModificationHandler.cs
src/DbLinq/Data/Linq/Implementation/QueryProvider.cs
src/DbLinq/Data/Linq/Implementation/VendorProvider.cs
src/DbLinq/Data/Linq/ITable.cs
src/DbLinq/Data/Linq/IVendorProvider.cs
src/DbLinq/Data/Linq/Mapping/AttributedAbstractMetaDataMember.cs
src/DbLinq/Data/Linq/Mapping/AttributedAssociationMetaDataMember.cs
src/DbLinq/Data/Linq/Mapping/AttributedColumnMetaDataMember.cs
src/DbLinq/Data/Linq/Mapping/AttributedMetaAssociation.cs
src/DbLinq/Data/Linq/Mapping/AttributedMetaFunction.cs
src/DbLinq/Data/Linq/Mapping/AttributedMetaModel.cs
src/DbLinq/Data/Linq/Mapping/AttributedMetaTable.cs
src/DbLinq/Data/Linq/Mapping/AttributedMetaType.cs
src/DbLinq/Data/Linq/Mapping/AttributeMappingSource.cs
src/DbLinq/Data/Linq/Mapping/LambdaMetaAccessor.cs
src/DbLinq/Data/Linq/Mapping/MappingContext.cs
src/DbLinq/Data/Linq/Mapping/XmlMappingSource.cs
src/DbLinq/Data/Linq/RefreshMode.cs
src/DbLinq/Data/Linq/Sql/SqlLiteralPart.cs
src/DbLinq/Data/Linq/Sql/SqlParameterPart.cs
src/DbLinq/Data/Linq/Sql/SqlPart.cs
src/DbLinq/Data/Linq/Sql/SqlStatement.cs
src/DbLinq/Data/Linq/Sql/SqlStatementBuilder.cs
src/DbLinq/Data/Linq/SqlClient/FirebirdProvider.cs
src/DbLinq/Data/Linq/SqlClient/IngresProvider.cs
src/DbLinq/Data/Linq/SqlClient/MySqlProvider.cs
src/DbLinq/Data/Linq/SqlClient/OracleProvider.cs
src/DbLinq/Data/Linq/SqlClient/PostgreSqlProvider.cs
src/DbLinq/Data/Linq/SqlClient/Sql2000Provider.cs
src/DbLinq/Data/Linq/SqlClient/Sql2005Provider.cs
src/DbLinq/Data/Linq/SqlClient/Sql2008Provider.cs
src/DbLinq/Data/Linq/SqlClient/SqliteProvider.cs
src/DbLinq/Data/Linq/SqlClient/SqlServerProvider.cs
src/DbLinq/Data/Linq/Sugar/AbstractQuery.cs
src/DbLinq/Data/Linq/Sugar/BuilderContext.cs
src/DbLinq/Data/Linq/Sugar/DeleteQuery.cs
src/DbLinq/Data/Linq/Sugar/DirectQuery.cs
src/DbLinq/Data/Linq/Sugar/Error.cs
src/DbLinq/Data/Linq/Sugar/ExpressionChain.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/ExpressionMutatorExtensions.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/ExpressionMutatorFactory.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/BinaryExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/ConditionalExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/ConstantExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/IMemberBindingMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/InvocationExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/LambdaExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/ListInitExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberAssignmentMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberBindingMutatorFactory.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberInitExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberListBindingMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MemberMemberBindingMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/MethodCallExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/NewArrayExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/NewExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/ParameterExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/TypeBinaryExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionMutator/Implementation/UnaryExpressionMutator.cs
src/DbLinq/Data/Linq/Sugar/ExpressionPrecedence.cs
src/DbLinq/Data/Linq/Sugar/ExpressionQuery.cs
src/DbLinq/Data/Linq/Sugar/Expressions/ColumnExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/CustomExpressionType.cs
src/DbLinq/Data/Linq/Sugar/Expressions/EntitySetExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/ExpressionTranslator.cs
src/DbLinq/Data/Linq/Sugar/Expressions/GroupExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/IExecutableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/IMutableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/InputParameterExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/MetaTableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/MutableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/ObjectInputParameterExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/ObjectOutputParameterExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/OperandsMutableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/OrderByExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/SelectExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/SelectOperatorType.cs
src/DbLinq/Data/Linq/Sugar/Expressions/SpecialExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/SpecialExpressionType.cs
src/DbLinq/Data/Linq/Sugar/Expressions/StartIndexOffsetExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/SubSelectExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/TableExpression.cs
src/DbLinq/Data/Linq/Sugar/Expressions/TableJoinType.cs
src/DbLinq/Data/Linq/Sugar/ExpressionTier.cs
src/DbLinq/Data/Linq/Sugar/IDataMapper.cs
src/DbLinq/Data/Linq/Sugar/IDataRecordReader.cs
src/DbLinq/Data/Linq/Sugar/IExpressionDispatcher.cs
src/DbLinq/Data/Linq/Sugar/IExpressionLanguageParser.cs
src/DbLinq/Data/Linq/Sugar/IExpressionOptimizer.cs
src/DbLinq/Data/Linq/Sugar/IExpressionQualifier.cs
src/DbLinq/Data/Linq/Sugar/Implementation/DataMapper.cs
src/DbLinq/Data/Linq/Sugar/Implementation/DataRecordReader.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionDispatcher.Analyzer.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionDispatcher.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionDispatcher.Registrar.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionLanguageParser.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionOptimizer.cs
src/DbLinq/Data/Linq/Sugar/Implementation/ExpressionQualifier.cs
src/DbLinq/Data/Linq/Sugar/Implementation/LineGrouping.cs
src/DbLinq/Data/Linq/Sugar/Implementation/PrequelAnalyzer.cs
src/DbLinq/Data/Linq/Sugar/Implementation/QueryBuilder.cs
src/DbLinq/Data/Linq/Sugar/Implementation/QueryBuilder.Upsert.cs
src/DbLinq/Data/Linq/Sugar/Implementation/QueryCache.cs
src/DbLinq/Data/Linq/Sugar/Implementation/QueryRunner.cs
src/DbLinq/Data/Linq/Sugar/Implementation/SpecialExpressionTranslator.cs
src/DbLinq/Data/Linq/Sugar/Implementation/SqlBuilder.cs
src/DbLinq/Data/Linq/Sugar/IPrequelAnalyzer.cs
src/DbLinq/Data/Linq/Sugar/IQueryBuilder.cs
src/DbLinq/Data/Linq/Sugar/IQueryCache.cs
src/DbLinq/Data/Linq/Sugar/IQueryRunner.cs
src/DbLinq/Data/Linq/Sugar/ISpecialExpressionTranslator.cs
src/DbLinq/Data/Linq/Sugar/ISqlBuilder.cs
src/DbLinq/Data/Linq/Sugar/ParameterizedQuery.cs
src/DbLinq/Data/Linq/Sugar/QueryContext.cs
src/DbLinq/Data/Linq/Sugar/SelectQuery.cs
src/DbLinq/Data/Linq/Sugar/UpsertQuery.cs
src/DbLinq/Data/Linq/Table.cs
src/DbLinq/DbLinqToDoAttribute.cs
src/DbLinq/Factory/DbLinqAttribute.cs
src/DbLinq/Factory/Implementation/ReflectionObjectFactory.cs
src/DbLinq/Factory/IObjectFactory.cs
src/DbLinq/Factory/ObjectFactory.cs
src/DbLinq/Language/ILanguages.cs
src/DbLinq/Language/ILanguageWords.cs
src/DbLinq/Language/Implementation/AbstractEndPluralWords.cs
src/DbLinq/Language/Implementation/AbstractWords.cs
src/DbLinq/Language/Implementation/Languages.cs
src/DbLinq/Language/Implementation/NoLanguageWords.cs
src/DbLinq/Schema/AssociationName.cs
src/DbLinq/Schema/Case.cs
src/DbLinq/Schema/ColumnName.cs
src/DbLinq/Schema/Dbml/Adapter/ArrayAdapter.cs
src/DbLinq/Schema/Dbml/Adapter/CsvArrayAdapter.cs
src/DbLinq/Schema/Dbml/Adapter/EnumType.cs
src/DbLinq/Schema/Dbml/Adapter/INamedType.cs
src/DbLinq/Schema/Dbml/Adapter/ISimpleList.cs
src/DbLinq/Schema/Dbml/Adapter/SpecifiedPropertyUpdater.cs
src/DbLinq/Schema/Dbml/DatabaseSerializer.cs
src/DbLinq/Schema/Dbml/DbmlSchema.Adapter.cs
src/DbLinq/Schema/Dbml/DbmlSchema.cs
src/DbLinq/Schema/Dbml/DbmlSerializer.cs
src/DbLinq/Schema/Implementation/NameFormatter.cs
src/DbLinq/Schema/INameFormatter.cs
src/DbLinq/Schema/Name.cs
src/DbLinq/Schema/NameFormat.cs
src/DbLinq/Schema/ParameterName.cs
src/DbLinq/Schema/ProcedureName.cs
src/DbLinq/Schema/SchemaName.cs
src/DbLinq/Schema/TableName.cs
src/DbLinq/Schema/WordsExtraction.cs
src/DbLinq/System.Data.Linq/Binary.cs
src/DbLinq/System.Data.Linq/ChangeConflictCollection.cs
src/DbLinq/System.Data.Linq/ChangeConflictException.cs
src/DbLinq/System.Data.Linq/CompiledQuery.cs
src/DbLinq/System.Data.Linq/ConflictMode.cs
src/DbLinq/System.Data.Linq/DBConvert.cs
src/DbLinq/System.Data.Linq/DuplicateKeyException.cs
src/DbLinq/System.Data.Linq/ForeignKeyReferenceAlreadyHasValueException.cs
src/DbLinq/System.Data.Linq/IFunctionResult.cs
src/DbLinq/System.Data.Linq/IMultipleResults.cs
src/DbLinq/System.Data.Linq/ISingleResult.cs
src/DbLinq/System.Data.Linq/Link.cs
src/DbLinq/System.Data.Linq/MemberChangeConflict.cs
src/DbLinq/System.Data.Linq/ModifiedMemberInfo.cs
src/DbLinq/System.Data.Linq/ObjectChangeConflict.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/AssociationAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/AutoSync.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/ColumnAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/DataAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/DatabaseAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/FunctionAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/InheritanceMappingAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MappingSource.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaAccessor.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaAccessor_2.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaAssociation.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaDataMember.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaFunction.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaModel.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaParameter.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaTable.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/MetaType.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/ParameterAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/ProviderAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/ResultTypeAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/TableAttribute.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.Mapping/UpdateCheck.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.SqlClient.Implementation/ObjectMaterializer.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.SqlClient/SqlHelpers.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.SqlClient/SqlMethods.cs
src/DbLinq/System.Data.Linq/System.Data.Linq.SqlClient/SqlProvider.cs
src/DbLinq/Util/DataCommand.cs
src/DbLinq/Util/DbmlExtensions.cs
src/DbLinq/Util/ExpressionChainEqualityComparer.cs
src/DbLinq/Util/ExpressionEqualityComparer.cs
src/DbLinq/Util/IDataRecordExtensions.cs
src/DbLinq/Util/IDataTypeExtensions.cs
src/DbLinq/Util/IDbDataParameterExtensions.cs
src/DbLinq/Util/IThreadSafeDictionary.cs
src/DbLinq/Util/LambdaComparer.cs
src/DbLinq/Util/MemberInfoExtensions.cs
src/DbLinq/Util/Output.cs
src/DbLinq/Util/OutputLevel.cs
src/DbLinq/Util/Page.cs
src/DbLinq/Util/Profiler.cs
src/DbLinq/Util/QuotesHelper.cs
src/DbLinq/Util/ReferenceEqualityComparer.cs
src/DbLinq/Util/ReflectionExtensions.cs
src/DbLinq/Util/ReflectionUtility.cs
src/DbLinq/Util/StringExtensions.cs
src/DbLinq/Util/TextWriterExtension.cs
src/DbLinq/Util/ThreadSafeDictionary.cs
src/DbLinq/Util/TypeConvert.cs
src/DbLinq/Util/TypeExtensions.cs
src/DbLinq/Util/TypeLoader.cs
src/DbLinq/Vendor/DbSchemaLoader.cs
src/DbLinq/Vendor/IDataName.cs
src/DbLinq/Vendor/IDataTableColumn.cs
src/DbLinq/Vendor/IDataType.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.Columns.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.DataName.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.DataTableColumn.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.ForeignKey.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.Name.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.StoredProcedures.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.Tables.cs
src/DbLinq/Vendor/Implementation/SchemaLoader.TypeMapping.cs
src/DbLinq/Vendor/Implementation/SqlProvider.cs
src/DbLinq/Vendor/Implementation/Vendor.cs
src/DbLinq/Vendor/Implementation/Vendor.ProcedureResult.cs
src/DbLinq/Vendor/INameAliases.cs
src/DbLinq/Vendor/ISchemaLoader.cs
src/DbLinq/Vendor/ISqlProvider.cs
src/DbLinq/Vendor/IVendor.cs
src/DbLinq/Vendor/VendorAttribute.cs
src/DbLinq.ProductInfo.cs
src/DbMetal/AbstractParameters.cs
src/DbMetal/Configuration/ProvidersSection.cs
src/DbMetal/Generator/AttributeDefinition.cs
src/DbMetal/Generator/CodeDomGenerator.cs
src/DbMetal/Generator/CodeWriter.cs
src/DbMetal/Generator/EntityInterface/IImplementation.cs
src/DbMetal/Generator/EntityInterface/Implementation/IModifiedImplementation.cs
src/DbMetal/Generator/EntityInterface/Implementation/INotifyPropertyChangedImplementation.cs
src/DbMetal/Generator/EntityInterface/Implementation/INotifyPropertyChangingImplementation.cs
src/DbMetal/Generator/EntityInterface/Implementation/InterfaceImplementation.cs
src/DbMetal/Generator/GenerationContext.cs
src/DbMetal/Generator/ICodeGenerator.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Context.Ctor.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Procedure.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CSCodeGenerator.cs
src/DbMetal/Generator/Implementation/CodeTextGenerator/CSCodeWriter.cs
src/DbMetal/Generator/Implementation/Processor.cs
src/DbMetal/Generator/Implementation/SchemaLoaderFactory.cs
src/DbMetal/Generator/IProcessor.cs
src/DbMetal/Generator/ISchemaLoaderFactory.cs
src/DbMetal/Generator/ParameterDefinition.cs
src/DbMetal/Generator/SpecificationDefinition.cs
src/DbMetal/Language/EnglishWords.cs
src/DbMetal/Language/FrenchWords.cs
src/DbMetal/Language/GermanWords.cs
src/DbMetal/Mono/Options.cs
src/DbMetal/Parameters.cs
src/DbMetal/Program.cs
src/DbMetal/Properties/Settings.Designer.cs
src/DbMetal/Reference.cs
src/DbMetal/Schema/DbmlRename.cs
src/DbMetal/Schema/DbmlRenameLoader.cs
src/DbMetal/Schema/NameAliasesLoader.cs
src/DbMetal/Schema/TableAlias.cs
src/DbMetal/Utility/EnvironmentExtension.cs
src/DbMetal/Utility/VariablesExtension.cs

View File

@@ -0,0 +1,57 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Data;
#if MONO_STRICT
using System.Data.Linq;
#else
using DbLinq.Data.Linq;
#endif
namespace DbLinq.Firebird
{
#if !MONO_STRICT
public
#endif
class FirebirdDataContext : DataContext
{
#if FIREBIRDSQL_IS_REFERENCED
public FbDataContext(string connStr)
: base(new global::FirebirdSql.Data.FirebirdClient.FbConnection(connStr), new FbVendor())
{
}
#endif
public FirebirdDataContext(IDbConnection conn)
#if MONO_STRICT
: base(conn)
#else
: base(conn, new FirebirdVendor())
#endif
{
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbLinq.Data.Linq.Sugar.Expressions;
namespace DbLinq.Firebird
{
class FirebirdExpressionTranslator : ExpressionTranslator
{
public override SelectExpression OuterExpression(SelectExpression e)
{
// Check for (from f in foo orderby f.Field select f).Count() trees
// Firebird doesn't support 'ORDER BY' for 'SELECT COUNT(*)'.
if (e.Operands.Select(o => o as SpecialExpression)
.Where(o => o != null)
.Where(s => s.SpecialNodeType == SpecialExpressionType.Count)
.Any())
{
e.OrderBy.Clear();
}
return e;
}
}
}

View File

@@ -0,0 +1,91 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DbLinq.Util;
using DbLinq.Vendor;
namespace DbLinq.Firebird
{
partial class FirebirdSchemaLoader
{
protected virtual IDataTableColumn ReadColumn(IDataReader rdr)
{
var column = new DataTableColumn();
int field = 0;
column.TableSchema = rdr.GetAsString(field++);
column.TableName = rdr.GetAsString(field++).Trim();
column.ColumnName = rdr.GetAsString(field++).Trim();
column.Nullable = rdr.GetAsBool(field++);
column.SqlType = rdr.GetAsString(field++).Trim();
column.Generated = rdr.GetAsBool(field++);
//column.Unsigned = column.FullType.Contains("unsigned");
column.PrimaryKey = rdr.GetAsBool(field++);
column.Length = rdr.GetAsNullableNumeric<long>(field++);
column.Precision = rdr.GetAsNullableNumeric<int>(field++);
column.Scale = rdr.GetAsNullableNumeric<int>(field++);
column.DefaultValue = rdr.GetAsString(field++);
FormatFullType(column);
return column;
}
private void FormatFullType(DataTableColumn column)
{
// TODO: Implement.
}
protected override IList<IDataTableColumn> ReadColumns(IDbConnection connectionString, string databaseName)
{
const string sql = @"
select 'Foo' ""TableSchema""
, rf.RDB$RELATION_NAME ""TableName""
, rf.RDB$FIELD_NAME ""ColumnName""
, case when rf.RDB$NULL_FLAG is null then 1 else 0 end ""Nullable""
, t.RDB$TYPE_NAME ""Type""
, case when f.RDB$COMPUTED_SOURCE is null then 0 else 1 end ""Generated""
, case when exists(select *
from RDB$RELATION_CONSTRAINTS rc
inner join RDB$INDEX_SEGMENTS xs on xs.RDB$INDEX_NAME = rc.RDB$INDEX_NAME
where rc.RDB$RELATION_NAME = rf.RDB$RELATION_NAME and xs.RDB$FIELD_NAME = rf.RDB$FIELD_NAME
and rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY') then 1 else 0 end ""PrimaryKey""
, f.RDB$FIELD_LENGTH ""Length""
, f.RDB$FIELD_PRECISION ""Precision""
, f.RDB$FIELD_SCALE ""Scale""
, rf.RDB$DEFAULT_VALUE ""DefaultValue""
from RDB$RELATION_FIELDS rf
inner join RDB$FIELDS f on f.RDB$FIELD_NAME = rf.RDB$FIELD_SOURCE
inner join RDB$TYPES t on t.RDB$TYPE = f.RDB$FIELD_TYPE and t.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
where rf.RDB$SYSTEM_FLAG = 0
order by rf.RDB$RELATION_NAME, rf.RDB$FIELD_POSITION
";
return DataCommand.Find<IDataTableColumn>(connectionString, sql, "@db", databaseName, ReadColumn);
}
}
}

View File

@@ -0,0 +1,91 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
namespace DbLinq.Firebird
{
partial class FirebirdSchemaLoader
{
protected class DataConstraint
{
public string ConstraintName;
public string TableSchema;
public string TableName;
public string ColumnName;
public string ReferencedTableSchema;
public string ReferencedTableName;
public string ReferencedColumnName;
public override string ToString()
{
string detail = ConstraintName == "PRIMARY"
? TableName + " PK"
: ConstraintName;
return "KeyColUsage " + detail;
}
}
protected virtual DataConstraint ReadConstraint(IDataReader rdr)
{
DataConstraint constraint = new DataConstraint();
int field = 0;
constraint.ConstraintName = rdr.GetAsString(field++);
constraint.TableSchema = rdr.GetAsString(field++);
constraint.TableName = rdr.GetAsString(field++).Trim();
constraint.ColumnName = rdr.GetAsString(field++).Trim();
constraint.ReferencedTableSchema = rdr.GetAsString(field++);
constraint.ReferencedTableName = rdr.GetAsString(field++).Trim();
constraint.ReferencedColumnName = rdr.GetAsString(field++).Trim();
return constraint;
}
protected virtual List<DataConstraint> ReadConstraints(IDbConnection conn, string db)
{
// TODO: Only supports constrains where the columns have the same name.
string sql = @"
select tbl.RDB$CONSTRAINT_NAME ""ConstraintName""
, 'Foo' ""TableSchema""
, tbl.RDB$RELATION_NAME ""TableName""
, col.RDB$FIELD_NAME ""ColumnName""
, 'Foo' ""ReferencedTableSchema""
, rtbl.RDB$RELATION_NAME ""ReferencedTableName""
, rcol.RDB$FIELD_NAME ""ReferencedColumnName""
from RDB$RELATION_CONSTRAINTS tbl
inner join RDB$INDEX_SEGMENTS col on col.RDB$INDEX_NAME = tbl.RDB$INDEX_NAME
inner join RDB$REF_CONSTRAINTS ref on ref.RDB$CONSTRAINT_NAME = tbl.RDB$CONSTRAINT_NAME
inner join RDB$RELATION_CONSTRAINTS rtbl on rtbl.RDB$CONSTRAINT_NAME = ref.RDB$CONST_NAME_UQ
inner join RDB$INDEX_SEGMENTS rcol on rcol.RDB$INDEX_NAME = rtbl.RDB$INDEX_NAME
where tbl.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' and col.RDB$FIELD_NAME = rcol.RDB$FIELD_NAME
order by tbl.RDB$RELATION_NAME
";
return DataCommand.Find<DataConstraint>(conn, sql, "@db", db, ReadConstraint);
}
}
}

View File

@@ -0,0 +1,112 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
namespace DbLinq.Firebird
{
partial class FirebirdSchemaLoader
{
public class DataStoredProcedure
{
public string TableSchema;
public string Name;
public string Type;
public string ParameterName;
public bool IsOutputParameter;
public string ParameterType;
public long? Length;
public int? Precision;
public int? Scale;
public string DefaultValue;
public bool BodyContainsSelectStatement;
public override string ToString()
{
return "ProcRow " + Name;
}
}
DataStoredProcedure ReadProcedure(IDataReader rdr)
{
DataStoredProcedure procedure = new DataStoredProcedure();
int field = 0;
procedure.TableSchema = rdr.GetAsString(field++);
procedure.Name = rdr.GetAsString(field++).Trim();
procedure.Type = rdr.GetAsString(field++);
procedure.ParameterName = rdr.GetAsString(field++).Trim();
procedure.IsOutputParameter = rdr.GetAsBool(field++);
procedure.ParameterType = rdr.GetAsString(field++).Trim();
procedure.Length = rdr.GetAsNullableNumeric<long>(field++);
procedure.Precision = rdr.GetAsNullableNumeric<int>(field++);
procedure.Scale = rdr.GetAsNullableNumeric<int>(field++);
procedure.DefaultValue = rdr.GetAsString(field++);
procedure.BodyContainsSelectStatement = rdr.GetAsBool(field++);
return procedure;
}
public List<DataStoredProcedure> ReadProcedures(IDbConnection conn, string db)
{
string sql = @"
select 'Foo' ""TableSchema""
, p.RDB$PROCEDURE_NAME ""Name""
, 'PROCEDURE' ""Type""
, pp.RDB$PARAMETER_NAME ""ParameterName""
, pp.RDB$PARAMETER_TYPE ""IsOutputParameter""
, t.RDB$TYPE_NAME ""ParameterType""
, f.RDB$FIELD_LENGTH ""Length""
, f.RDB$FIELD_PRECISION ""Precision""
, f.RDB$FIELD_SCALE ""Scale""
, pp.RDB$DEFAULT_VALUE ""DefaultValue""
, case when p.RDB$PROCEDURE_OUTPUTS is null then 0 else 1 end ""BodyContainsSelectStatement""
from RDB$PROCEDURES p
inner join RDB$PROCEDURE_PARAMETERS pp on pp.RDB$PROCEDURE_NAME = p.RDB$PROCEDURE_NAME
inner join RDB$FIELDS f on f.RDB$FIELD_NAME = pp.RDB$FIELD_SOURCE
inner join RDB$TYPES t on t.RDB$TYPE = f.RDB$FIELD_TYPE and t.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
where p.RDB$SYSTEM_FLAG = 0
union
select @db ""TableSchema""
, p.RDB$FUNCTION_NAME ""Name""
, 'FUNCTION' ""Type""
, pp.RDB$FUNCTION_NAME ""ParameterName""
, case when pp.rdb$mechanism = 5 then 1 else 0 end ""IsOutputParameter""
, t.RDB$TYPE_NAME ""ParameterType""
, pp.RDB$FIELD_LENGTH ""Length""
, pp.RDB$FIELD_PRECISION ""Precision""
, pp.RDB$FIELD_SCALE ""Scale""
, null ""DefaultValue""
, 0 ""BodyContainsSelectStatement""
from RDB$FUNCTIONS p
inner join RDB$FUNCTION_ARGUMENTS pp on pp.RDB$FUNCTION_NAME = p.RDB$FUNCTION_NAME
inner join RDB$TYPES t on t.RDB$TYPE = pp.RDB$FIELD_TYPE and t.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
where p.RDB$SYSTEM_FLAG = 0
";
return DataCommand.Find<DataStoredProcedure>(conn, sql, "@db", db.ToLower(), ReadProcedure);
}
}
}

View File

@@ -0,0 +1,56 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
using DbLinq.Vendor;
using DbLinq.Vendor.Implementation;
namespace DbLinq.Firebird
{
#if !MONO_STRICT
public
#endif
partial class FirebirdSchemaLoader
{
public override IList<IDataName> ReadTables(IDbConnection connectionString, string databaseName)
{
// note: the ReadDataNameAndSchema relies on information order
const string sql = @"
select RDB$RELATION_NAME ""TableName""
, 'Foo' ""TableSchema""
from RDB$RELATIONS
where RDB$SYSTEM_FLAG = 0
order by RDB$RELATION_NAME
";
return DataCommand.Find<IDataName>(connectionString, sql, "@db", databaseName, ReadDataNameAndSchema)
.ConvertAll(delegate(IDataName dn) {
dn.Name = dn.Name.Trim();
return dn;
});
}
}
}

View File

@@ -0,0 +1,267 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using DbLinq.Schema;
using DbLinq.Schema.Dbml;
using DbLinq.Util;
using DbLinq.Vendor;
using DbLinq.Vendor.Implementation;
namespace DbLinq.Firebird
{
partial class FirebirdSchemaLoader : SchemaLoader
{
private readonly IVendor vendor = new FirebirdVendor();
public override IVendor Vendor { get { return vendor; } set { } }
protected override TableName CreateTableName(string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat)
{
return CreateTableName(dbTableName, dbSchema, nameAliases, nameFormat, WordsExtraction.FromDictionary);
}
/// <summary>
/// Gets a usable name for the database.
/// </summary>
/// <param name="databaseName">Name of the database.</param>
/// <returns></returns>
protected override string GetDatabaseName(string databaseName)
{
return Path.GetFileNameWithoutExtension(databaseName);
}
protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
{
// TODO: debug stored procedures support
return;
var procs = ReadProcedures(conn, schemaName.DbName);
foreach (DataStoredProcedure proc in procs)
{
var procedureName = CreateProcedureName(proc.Name, proc.TableSchema, nameFormat);
var func = new Function();
func.Name = procedureName.DbName;
func.Method = procedureName.MethodName;
func.IsComposable = string.Compare(proc.Type, "FUNCTION") == 0;
func.BodyContainsSelectStatement = proc.BodyContainsSelectStatement;
ParseProcParams(proc, func);
schema.Functions.Add(func);
}
}
protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
{
var constraints = ReadConstraints(conn, schemaName.DbName);
//sort tables - parents first (this is moving to SchemaPostprocess)
//TableSorter.Sort(tables, constraints);
foreach (DataConstraint keyColRow in constraints)
{
//find my table:
string fullKeyDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => fullKeyDbName == t.Name);
if (table == null)
{
bool ignoreCase = true;
table = schema.Tables.FirstOrDefault(t => 0 == string.Compare(fullKeyDbName, t.Name, ignoreCase));
if (table == null)
{
WriteErrorLine("ERROR L46: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
continue;
}
}
bool isForeignKey = keyColRow.ConstraintName != "PRIMARY"
&& keyColRow.ReferencedTableName != null;
if (isForeignKey)
{
LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName, keyColRow.ReferencedTableSchema,
keyColRow.ConstraintName, nameFormat, names);
}
}
}
protected void ParseProcParams(DataStoredProcedure inputData, Function outputFunc)
{
//string paramString = inputData.ParamList;
//if (string.IsNullOrEmpty(paramString))
//{
// //nothing to parse
//}
//else
//{
// string[] parts = paramString.Split(',');
// foreach (string part in parts) //part='OUT param1 int'
// {
// DbLinq.Schema.Dbml.Parameter paramObj = ParseParameterString(part);
// if (paramObj != null)
// outputFunc.Parameters.Add(paramObj);
// }
//}
//if (!string.IsNullOrEmpty(inputData.Returns))
//{
// var paramRet = new Return();
// paramRet.DbType = inputData.Returns;
// paramRet.Type = ParseDbType(null, inputData.Returns);
// outputFunc.Return = paramRet;
//}
}
/// <summary>
/// parse strings such as 'INOUT param2 INT' or 'param4 varchar ( 32 )'
/// </summary>
/// <param name="paramStr"></param>
/// <returns></returns>
protected DbLinq.Schema.Dbml.Parameter ParseParameterString(string param)
{
param = param.Trim();
var inOut = DbLinq.Schema.Dbml.ParameterDirection.In;
if (param.StartsWith("IN", StringComparison.CurrentCultureIgnoreCase))
{
inOut = DbLinq.Schema.Dbml.ParameterDirection.In;
param = param.Substring(2).Trim();
}
if (param.StartsWith("INOUT", StringComparison.CurrentCultureIgnoreCase))
{
inOut = DbLinq.Schema.Dbml.ParameterDirection.InOut;
param = param.Substring(5).Trim();
}
if (param.StartsWith("OUT", StringComparison.CurrentCultureIgnoreCase))
{
inOut = DbLinq.Schema.Dbml.ParameterDirection.Out;
param = param.Substring(3).Trim();
}
int indxSpace = param.IndexOfAny(new char[] { ' ', '\t' });
if (indxSpace == -1)
return null; //cannot find space between varName and varType
string varName = param.Substring(0, indxSpace);
string varType = param.Substring(indxSpace + 1);
var paramObj = new Parameter();
paramObj.Direction = inOut;
paramObj.Name = varName;
paramObj.DbType = varType;
paramObj.Type = ParseDbType(varName, varType);
return paramObj;
}
static System.Text.RegularExpressions.Regex re_CHARSET = new System.Text.RegularExpressions.Regex(@" CHARSET \w+$");
/// <summary>
/// given 'CHAR(30)', return 'string'
/// </summary>
protected string ParseDbType(string columnName, string dbType1)
{
//strip 'CHARSET latin1' from the end
string dbType2 = re_CHARSET.Replace(dbType1, "");
var dataType = new DataType();
dataType.UnpackRawDbType(dbType2);
return MapDbType(columnName, dataType).ToString();
}
/// <summary>
/// This is a hack while I figure out a way to produce Dialect 3 types.
/// </summary>
/// <param name="columnName"></param>
/// <param name="dataType"></param>
/// <returns></returns>
protected override System.Type MapDbType(string columnName, IDataType dataType)
{
switch (dataType.SqlType)
{
// string
case "CSTRING":
case "TEXT":
case "VARYING":
return typeof(String);
// int16
case "SHORT":
if (dataType.Unsigned ?? false)
return typeof(UInt16);
return typeof(Int16);
// int32
case "LONG":
if (dataType.Unsigned ?? false)
return typeof(UInt32);
return typeof(Int32);
// int64
case "INT64":
return typeof(Int64);
// single
case "FLOAT":
return typeof(Single);
// double
case "DOUBLE":
return typeof(Double);
// decimal
case "QUAD":
return typeof(Decimal);
// time interval
case "TIME":
return typeof(TimeSpan);
// date
case "TIMESTAMP":
case "DATE":
return typeof(DateTime);
// byte[]
case "BLOB":
case "BLOB_ID":
return typeof(Byte[]);
// if we fall to this case, we must handle the type
default:
return null;
}
}
}
}

View File

@@ -0,0 +1,126 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Linq;
using System.Collections.Generic;
using DbLinq.Vendor.Implementation;
using DbLinq.Data.Linq.Sql;
using DbLinq.Data.Linq.Sugar.Expressions;
namespace DbLinq.Firebird
{
#if !MONO_STRICT
public
#endif
class FirebirdSqlProvider : SqlProvider
{
public override ExpressionTranslator GetTranslator()
{
return new FirebirdExpressionTranslator();
}
public override string GetParameterName(string nameBase)
{
return "@" + nameBase;
}
protected override SqlStatement GetLiteralCount(SqlStatement a)
{
return "COUNT(*)";
}
protected override SqlStatement GetLiteralStringConcat(SqlStatement a, SqlStatement b)
{
return SqlStatement.Format("{0} || {1}", a, b);
}
protected override SqlStatement GetLiteralStringToLower(SqlStatement a)
{
return string.Format("LOWER({0})", a);
}
protected override SqlStatement GetLiteralStringToUpper(SqlStatement a)
{
return string.Format("UPPER({0})", a);
}
protected override char SafeNameStartQuote { get { return ' '; } }
protected override char SafeNameEndQuote { get { return ' '; } }
/// <summary>
/// Returns a table alias
/// </summary>
/// <param name="table"></param>
/// <returns></returns>
public override string GetTable(string table)
{
var parts = table.Split('.');
return GetSafeName(parts[parts.Length - 1]);
}
/// <summary>
/// Returns a LIMIT clause around a SELECT clause
/// </summary>
/// <param name="select">SELECT clause</param>
/// <param name="limit">limit value (number of columns to be returned)</param>
/// <returns></returns>
public override SqlStatement GetLiteralLimit(SqlStatement select, SqlStatement limit)
{
string stmt = limit.Count == 2
? string.Format("SELECT FIRST {0}, LAST {1}", limit[0].Sql, limit[1].Sql)
: string.Format("SELECT FIRST {0}", limit[0].Sql);
return select.Replace("SELECT", stmt, true);
}
public override SqlStatement GetLiteralLimit(SqlStatement select, SqlStatement limit, SqlStatement offset, SqlStatement offsetAndLimit)
{
string stmt = (limit.Count == 2
? string.Format("SELECT FIRST {0}, LAST {1} SKIP {2}", limit[0].Sql, limit[1].Sql, offset)
: string.Format("SELECT FIRST {0} SKIP {1}", limit[0].Sql, offset));
//string stmt = string.Format("SELECT FIRST {0} SKIP {1}", limit, offset);
return select.Replace("SELECT", stmt, true);
}
public override SqlStatement GetInsertIds(SqlStatement table, IList<SqlStatement> autoPKColumn, IList<SqlStatement> inputPKColumns, IList<SqlStatement> inputPKValues, IList<SqlStatement> outputColumns, IList<SqlStatement> outputParameters, IList<SqlStatement> outputExpressions)
{
// no parameters? no need to get them back
if (outputParameters.Count == 0)
return "";
// otherwise we keep track of the new values
return SqlStatement.Format("SELECT {0} INTO {1} FROM DUAL",
SqlStatement.Join(", ", (from outputExpression in outputExpressions select outputExpression.Replace(".NextVal", ".CurrVal", true)).ToArray()),
SqlStatement.Join(", ", outputParameters.ToArray()));
}
}
}

View File

@@ -0,0 +1,204 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Data.Common;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data.Linq.Mapping;
using System.Reflection;
using System.Data;
#if MONO_STRICT
using System.Data.Linq;
#else
using DbLinq.Data.Linq;
#endif
using DbLinq.Data.Linq.SqlClient;
using DbLinq.Util;
using DbLinq.Vendor;
namespace DbLinq.Firebird
{
[Vendor(typeof(FirebirdProvider))]
#if !MONO_STRICT
public
#endif
class FirebirdVendor : Vendor.Implementation.Vendor
{
public override string VendorName { get { return "FirebirdSql"; } }
protected readonly FirebirdSqlProvider sqlProvider = new FirebirdSqlProvider();
public override ISqlProvider SqlProvider { get { return sqlProvider; } }
/// <summary>
/// call mysql stored proc or stored function,
/// optionally return DataSet, and collect return params.
/// </summary>
public override System.Data.Linq.IExecuteResult ExecuteMethodCall(DataContext context, MethodInfo method
, params object[] inputValues)
{
if (method == null)
throw new ArgumentNullException("L56 Null 'method' parameter");
//check to make sure there is exactly one [FunctionEx]? that's below.
//FunctionAttribute functionAttrib = GetFunctionAttribute(method);
var functionAttrib = context.Mapping.GetFunction(method);
ParameterInfo[] paramInfos = method.GetParameters();
//int numRequiredParams = paramInfos.Count(p => p.IsIn || p.IsRetval);
//if (numRequiredParams != inputValues.Length)
// throw new ArgumentException("L161 Argument count mismatch");
string sp_name = functionAttrib.MappedName;
// picrap: is there any way to abstract some part of this?
using (IDbCommand command = context.Connection.CreateCommand())
{
command.CommandText = sp_name;
//FbSqlCommand command = new FbSqlCommand("select * from hello0()");
int currInputIndex = 0;
List<string> paramNames = new List<string>();
for (int i = 0; i < paramInfos.Length; i++)
{
ParameterInfo paramInfo = paramInfos[i];
//TODO: check to make sure there is exactly one [Parameter]?
ParameterAttribute paramAttrib = paramInfo.GetCustomAttributes(false).OfType<ParameterAttribute>().Single();
string paramName = "@" + paramAttrib.Name; //eg. '@param1'
paramNames.Add(paramName);
System.Data.ParameterDirection direction = GetDirection(paramInfo, paramAttrib);
//FbDbType dbType = FbSqlTypeConversions.ParseType(paramAttrib.DbType);
IDbDataParameter cmdParam = command.CreateParameter();
cmdParam.ParameterName = paramName;
//cmdParam.Direction = System.Data.ParameterDirection.Input;
if (direction == System.Data.ParameterDirection.Input || direction == System.Data.ParameterDirection.InputOutput)
{
object inputValue = inputValues[currInputIndex++];
cmdParam.Value = inputValue;
}
else
{
cmdParam.Value = null;
}
cmdParam.Direction = direction;
command.Parameters.Add(cmdParam);
}
if (!functionAttrib.IsComposable) // IsCompsable is false when we have a procedure
{
//procedures: under the hood, this seems to prepend 'CALL '
command.CommandType = System.Data.CommandType.StoredProcedure;
}
else
{
//functions: 'SELECT * FROM myFunction()' or 'SELECT * FROM hello(?s)'
command.CommandText = "SELECT * FROM " + command.CommandText + "("
+ string.Join(",", paramNames.ToArray()) + ")";
}
if (method.ReturnType == typeof(DataSet))
{
//unknown shape of resultset:
System.Data.DataSet dataSet = new DataSet();
//IDataAdapter adapter = new FbDataAdapter((FbCommand)command);
IDbDataAdapter adapter = CreateDataAdapter(context);
adapter.SelectCommand = command;
adapter.Fill(dataSet);
List<object> outParamValues = CopyOutParams(paramInfos, command.Parameters);
return new ProcedureResult(dataSet, outParamValues.ToArray());
}
else
{
object obj = command.ExecuteScalar();
List<object> outParamValues = CopyOutParams(paramInfos, command.Parameters);
return new ProcedureResult(obj, outParamValues.ToArray());
}
}
}
static System.Data.ParameterDirection GetDirection(ParameterInfo paramInfo, ParameterAttribute paramAttrib)
{
//strange hack to determine what's a ref, out parameter:
//http://lists.ximian.com/pipermain/mono-list/2003-March/012751.html
bool hasAmpersand = paramInfo.ParameterType.FullName.Contains('&');
if (paramInfo.IsOut)
return System.Data.ParameterDirection.Output;
if (hasAmpersand)
return System.Data.ParameterDirection.InputOutput;
return System.Data.ParameterDirection.Input;
}
/// <summary>
/// Collect all Out or InOut param values, casting them to the correct .net type.
/// </summary>
private List<object> CopyOutParams(ParameterInfo[] paramInfos, IDataParameterCollection paramSet)
{
List<object> outParamValues = new List<object>();
//Type type_t = typeof(T);
int i = -1;
foreach (IDbDataParameter param in paramSet)
{
i++;
if (param.Direction == System.Data.ParameterDirection.Input)
{
outParamValues.Add("unused");
continue;
}
object val = param.Value;
Type desired_type = paramInfos[i].ParameterType;
if (desired_type.Name.EndsWith("&"))
{
//for ref and out parameters, we need to tweak ref types, e.g.
// "System.Int32&, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
string fullName1 = desired_type.AssemblyQualifiedName;
string fullName2 = fullName1.Replace("&", "");
desired_type = Type.GetType(fullName2);
}
try
{
//fi.SetValue(t, val); //fails with 'System.Decimal cannot be converted to Int32'
//DbLinq.util.FieldUtils.SetObjectIdField(t, fi, val);
//object val2 = FieldUtils.CastValue(val, desired_type);
object val2 = TypeConvert.To(val, desired_type);
outParamValues.Add(val2);
}
catch (Exception)
{
//fails with 'System.Decimal cannot be converted to Int32'
//Logger.Write(Level.Error, "CopyOutParams ERROR L245: failed on CastValue(): " + ex.Message);
}
}
return outParamValues;
}
}
}

View File

@@ -0,0 +1,54 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Data;
#if MONO_STRICT
using System.Data.Linq;
#else
using DbLinq.Data.Linq;
#endif
namespace DbLinq.Ingres
{
/// <summary>
/// PgsqlDataContext allows easier one-parameter creation of a data context.
/// </summary>
#if !MONO_STRICT
public
#endif
class IngresDataContext : DataContext
{
public IngresDataContext(IDbConnection conn)
#if MONO_STRICT
: base(conn)
#else
: base(conn, new IngresVendor())
#endif
{
}
}
}

View File

@@ -0,0 +1,90 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
using DbLinq.Vendor;
namespace DbLinq.Ingres
{
partial class IngresSchemaLoader
{
protected virtual string GetFullType(IDataTableColumn column)
{
switch (column.SqlType.ToLower())
{
case "c":
case "char":
case "nchar":
case "varchar":
case "nvarchar":
case "long varchar":
case "text":
case "integer":
return column.SqlType + "(" + column.Length + ")";
case "decimal":
return column.SqlType + "(" + column.Length + ", " + column.Scale + ")";
default:
return column.SqlType;
}
}
protected virtual IDataTableColumn ReadColumn(IDataRecord rdr)
{
var column = new DataTableColumn();
int field = 0;
column.TableSchema = rdr.GetAsString(field++).Trim();
column.TableName = rdr.GetAsString(field++).Trim();
column.ColumnName = rdr.GetAsString(field++).Trim();
string nullableStr = rdr.GetAsString(field++);
column.Nullable = nullableStr == "Y";
column.SqlType = rdr.GetAsString(field++).Trim();
column.DefaultValue = rdr.GetAsString(field++);
column.Generated = column.DefaultValue != null && column.DefaultValue.StartsWith("next value for");
column.Length = rdr.GetAsNullableNumeric<long>(field++);
column.Scale = rdr.GetAsNullableNumeric<int>(field++);
column.FullType = GetFullType(column);
return column;
}
protected override IList<IDataTableColumn> ReadColumns(IDbConnection connectionString, string databaseName)
{
const string sql = @"SELECT t.table_owner, t.table_name, column_name, " +
"column_nulls, column_datatype, column_default_val, " +
"column_length, column_scale " +
"FROM iicolumns c join iitables t on " +
"(c.table_name=t.table_name and c.table_owner=t.table_owner) " +
"WHERE t.table_owner <> '$ingres' and t.table_type in ('T', 'V') " +
"AND t.table_name NOT LIKE 'ii%' " +
"ORDER BY column_sequence";
return DataCommand.Find<IDataTableColumn>(connectionString, sql, ReadColumn);
}
}
}

View File

@@ -0,0 +1,151 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
namespace DbLinq.Ingres
{
partial class IngresSchemaLoader
{
/// <summary>
/// row data from tables table_constraints, constraint_column_usage
/// </summary>
protected class DataConstraint
{
public string TableSchema;
public string TableName;
/// <summary>
/// P = PRIMARY KEY; R = FOREIGN KEY
/// </summary>
public string ConstraintType;
public override string ToString()
{
return (ConstraintType == "P" ?
"PK(" + TableName + "." + ColumnName + ")"
:
"FK(" + TableName + "." + ColumnName + " => " + ReferencedTableName + "." + ReferencedColumnName + ")");
}
public string ConstraintName;
/*
public string[] column_name_primaries
{
get
{
string[] tmp = TextSegment
.Replace("PRIMARY KEY(", "")
.Replace(")", "")
.Split(',');
for (int i = 0; i < tmp.Length; i++)
{
tmp[i] = tmp[i].Trim();
tmp[i] = tmp[i].Replace("\"", "");
}
return tmp;
}
}
*/
//public string[] column_name_primaries = new string[] { "", "" };
public string ColumnName;
public string ReferencedColumnName;
public string ReferencedTableSchema;
public string ReferencedTableName;
}
protected virtual DataConstraint ReadContraint(IDataReader rdr)
{
var constraint = new DataConstraint();
int field = 0;
constraint.ConstraintType = rdr.GetString(field++).Trim();
constraint.ConstraintName = rdr.GetString(field++).Trim();
constraint.TableSchema = rdr.GetString(field++).Trim();
constraint.TableName = rdr.GetString(field++).Trim();
constraint.ColumnName = rdr.GetString(field++).Trim();
constraint.ReferencedTableSchema = rdr.GetString(field++).Trim();
constraint.ReferencedTableName = rdr.GetString(field++).Trim();
constraint.ReferencedColumnName = rdr.GetString(field++).Trim();
return constraint;
}
protected virtual List<DataConstraint> ReadConstraints(IDbConnection conn, string db)
{
// picrap -> Thomas: I switched the FK orders without really understanding why
// because relations were inversed
string sql = @"
SELECT DISTINCT
c.constraint_type as constraint_type,
c.constraint_name as constraint_name,
k.schema_name as schema_name,
k.table_name as table_name,
k.column_name AS column_name,
'' as referenced_schema_name,
'' as referenced_table_name,
'' as referenced_column_name
FROM
iiconstraints c,
iikeys k
WHERE
k.constraint_name = c.constraint_name AND
c.constraint_type = 'P'
UNION
SELECT DISTINCT
c.constraint_type as constraint_type,
squeeze(f.table_name) || '_' || p.constraint_name as constraint_name,
f.schema_name as referenced_schema_name,
f.table_name as referenced_table_name,
f.column_name as referenced_column_name,
p.schema_name as schema_name,
p.table_name as table_name,
p.column_name as column_name
FROM
iikeys p,
iiconstraints c,
iiref_constraints rc,
iikeys f
WHERE
c.constraint_type = 'R' and
c.constraint_name = rc.ref_constraint_name AND
p.constraint_name = rc.unique_constraint_name AND
f.constraint_name = rc.ref_constraint_name AND
p.key_position = f.key_position
";
return DataCommand.Find<DataConstraint>(conn, sql, ReadContraint);
}
}
}

View File

@@ -0,0 +1,68 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DbLinq.Util;
namespace DbLinq.Ingres
{
partial class IngresSchemaLoader
{
/// <summary>
/// represents one row from pg_proc table
/// </summary>
protected class DataStoredProcedure
{
public string procedure_name;
public string procedure_owner;
public string text_segment;
public override string ToString() { return "Ing_Proc " + procedure_name; }
}
protected virtual DataStoredProcedure ReadProcedure(IDataReader rdr)
{
DataStoredProcedure procedure = new DataStoredProcedure();
int field = 0;
procedure.procedure_name = rdr.GetAsString(field++);
procedure.procedure_owner = rdr.GetAsString(field++);
procedure.text_segment = rdr.GetAsString(field++);
return procedure;
}
protected virtual List<DataStoredProcedure> ReadProcedures(IDbConnection conn, string db)
{
string sql = @"select procedure_name, procedure_owner, text_segment " +
"from iiprocedures where system_use='U' and " +
"procedure_owner!='$ingres' and text_sequence=1";
return DataCommand.Find<DataStoredProcedure>(conn, sql, ":db", db, ReadProcedure);
}
}
}

View File

@@ -0,0 +1,55 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Collections.Generic;
using System.Data;
using DbLinq.Util;
using DbLinq.Vendor;
namespace DbLinq.Ingres
{
#if !MONO_STRICT
public
#endif
partial class IngresSchemaLoader
{
protected override IDataName ReadDataNameAndSchema(IDataRecord dataRecord)
{
var dataName = new DataName { Name = dataRecord.GetAsString(0).TrimEnd(), Schema = dataRecord.GetAsString(1).TrimEnd() };
return dataName;
}
public override IList<IDataName> ReadTables(IDbConnection connectionString, string databaseName)
{
// note: the ReadDataNameAndSchema relies on information order
const string sql = @"SELECT table_name, table_owner FROM iitables " +
"WHERE table_owner <> '$ingres' " +
"AND table_type in ('T', 'V') " +
"AND table_name NOT LIKE 'ii%'";
return DataCommand.Find<IDataName>(connectionString, sql, ReadDataNameAndSchema);
}
}
}

View File

@@ -0,0 +1,117 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using DbLinq.Schema;
using DbLinq.Schema.Dbml;
using DbLinq.Util;
using DbLinq.Vendor;
using DbLinq.Vendor.Implementation;
namespace DbLinq.Ingres
{
#if !MONO_STRICT
public
#endif
partial class IngresSchemaLoader : SchemaLoader
{
private readonly Vendor.IVendor vendor = new IngresVendor();
public override Vendor.IVendor Vendor { get { return vendor; } set { } }
protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
{
//TableSorter.Sort(tables, constraints); //sort tables - parents first
var foreignKeys = ReadConstraints(conn, schemaName.DbName);
foreach (DataConstraint keyColRow in foreignKeys)
{
//find my table:
string constraintFullDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
if (table == null)
{
WriteErrorLine("ERROR L138: Table '"
+ keyColRow.TableName
+ "' not found for column "
+ keyColRow.ColumnName);
continue;
}
if (keyColRow.ConstraintType.Equals("P")) //'PRIMARY KEY'
{
//foreach (string pk_name in keyColRow.column_name_primaries)
//{
DbLinq.Schema.Dbml.Column primaryKeyCol = table.Type.Columns.First(c => c.Name == keyColRow.ColumnName);
primaryKeyCol.IsPrimaryKey = true;
//}
continue;
}
if (keyColRow.ConstraintType.Equals("R")) //'FOREIGN KEY'
{
// This is very bad...
if (!names.ColumnsNames[keyColRow.ReferencedTableName].ContainsKey(keyColRow.ReferencedColumnName))
continue;
LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName,
keyColRow.TableSchema,
keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName,
keyColRow.ReferencedTableSchema,
keyColRow.ConstraintName, nameFormat, names);
}
}
}
protected override System.Type MapDbType(string columnName, IDataType dataType)
{
switch (dataType.SqlType.ToLower())
{
case "float":
return typeof(Double);
case "integer":
switch (dataType.Length)
{
case 1:
return typeof(Byte);
case 2:
return typeof(Int16);
case 4:
return typeof(Int32);
case 8:
return typeof(Int64);
}
return MapDbType(columnName, null);
default:
return base.MapDbType(columnName, dataType);
}
}
}
}

View File

@@ -0,0 +1,109 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using DbLinq.Data.Linq.Sql;
using DbLinq.Vendor.Implementation;
namespace DbLinq.Ingres
{
#if !MONO_STRICT
public
#endif
class IngresSqlProvider : SqlProvider
{
public override SqlStatement GetInsertIds(SqlStatement table, IList<SqlStatement> autoPKColumn, IList<SqlStatement> inputPKColumns, IList<SqlStatement> inputPKValues, IList<SqlStatement> outputColumns, IList<SqlStatement> outputParameters, IList<SqlStatement> outputExpressions)
{
// no parameters? no need to get them back
if (outputParameters.Count == 0)
return "";
// otherwise we keep track of the new values
return SqlStatement.Format("SELECT {0}",
SqlStatement.Join(", ", (from outputExpression in outputExpressions
select outputExpression.Replace("next value", "current value", true)).ToArray())
);
}
public override string GetTableAlias (string nameBase)
{
return nameBase + "$";
}
public override SqlStatement GetLiteral (bool literal)
{
return literal == true ? "'Y'" : "'N'";
}
protected override SqlStatement GetLiteralCount(SqlStatement a)
{
return "COUNT(*)";
}
protected override SqlStatement GetLiteralStringToLower(SqlStatement a)
{
return string.Format("LOWER({0})", a);
}
protected override SqlStatement GetLiteralStringToUpper(SqlStatement a)
{
return string.Format("UPPER({0})", a);
}
public override SqlStatement GetLiteralLimit(SqlStatement select, SqlStatement limit)
{
// return string.Format("SELECT FIRST {0} FROM ({1})", limit, select);
var trimSelect = "SELECT ";
if (select.Count > 0 && select[0].Sql.StartsWith(trimSelect))
{
var selectBuilder = new SqlStatementBuilder(select);
var remaining = select[0].Sql.Substring(trimSelect.Length);
selectBuilder.Parts[0] = new SqlLiteralPart(remaining);
return SqlStatement.Format("SELECT FIRST {0} {1}", limit, selectBuilder.ToSqlStatement());
}
throw new ArgumentException("Invalid SELECT format");
}
public override SqlStatement GetLiteralLimit(SqlStatement select, SqlStatement limit, SqlStatement offset, SqlStatement offsetAndLimit)
{
// Ingres 9.2 and above support offset clauses now
return SqlStatement.Format("{0} OFFSET {1}", GetLiteralLimit(select, limit), offset);
}
public override string GetParameterName(string nameBase)
{
return (":" + nameBase).ToLower();
}
protected override SqlStatement GetLiteralStringConcat(SqlStatement a, SqlStatement b)
{
// This needs to be bracketed in case subsequent functions are called upon it
return SqlStatement.Format("({0} || {1})", a, b);
}
}
}

View File

@@ -0,0 +1,248 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Data;
using System.Linq;
using System.Data.Linq.Mapping;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using DbLinq.Data.Linq.SqlClient;
using DbLinq.Util;
using DbLinq.Vendor;
#if MONO_STRICT
using DataContext = System.Data.Linq.DataContext;
#else
using DataContext = DbLinq.Data.Linq.DataContext;
#endif
namespace DbLinq.Ingres
{
/// <summary>
/// Ingres - specific code.
/// </summary>
[Vendor(typeof(IngresProvider))]
#if !MONO_STRICT
public
#endif
class IngresVendor : Vendor.Implementation.Vendor
{
public override string VendorName { get { return "Ingres"; } }
protected readonly IngresSqlProvider sqlProvider = new IngresSqlProvider();
public override ISqlProvider SqlProvider { get { return sqlProvider; } }
//private string lastIdExpression = null;
private bool isReplaceable(IDbDataParameter param)
{
switch (param.DbType)
{
case DbType.String:
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
case DbType.Double:
return true;
}
return false;
}
private string getParamValueAsString(IDbDataParameter param)
{
switch (param.DbType)
{
case DbType.String:
return " '" + param.Value.ToString() + "' ";
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
case DbType.Double:
return param.Value.ToString();
}
throw new Exception("Not prepared to convert " + param.DbType.ToString());
}
protected void SetParameterType(IDbDataParameter parameter, PropertyInfo property, string literal)
{
object dbType = Enum.Parse(property.PropertyType, literal);
property.GetSetMethod().Invoke(parameter, new object[] { dbType });
}
protected void SetParameterType(IDbDataParameter parameter, string literal)
{
SetParameterType(parameter, parameter.GetType().GetProperty("IngresDbType"), literal);
}
/// <summary>
/// call mysql stored proc or stored function,
/// optionally return DataSet, and collect return params.
/// </summary>
public override System.Data.Linq.IExecuteResult ExecuteMethodCall(DataContext context, MethodInfo method
, params object[] inputValues)
{
if (method == null)
throw new ArgumentNullException("L56 Null 'method' parameter");
//check to make sure there is exactly one [FunctionEx]? that's below.
//FunctionAttribute functionAttrib = GetFunctionAttribute(method);
var functionAttrib = context.Mapping.GetFunction(method);
ParameterInfo[] paramInfos = method.GetParameters();
//int numRequiredParams = paramInfos.Count(p => p.IsIn || p.IsRetval);
//if (numRequiredParams != inputValues.Length)
// throw new ArgumentException("L161 Argument count mismatch");
string sp_name = functionAttrib.MappedName;
using (IDbCommand command = context.Connection.CreateCommand())
{
command.CommandText = sp_name;
//MySqlCommand command = new MySqlCommand("select hello0()");
int currInputIndex = 0;
List<string> paramNames = new List<string>();
for (int i = 0; i < paramInfos.Length; i++)
{
ParameterInfo paramInfo = paramInfos[i];
//TODO: check to make sure there is exactly one [Parameter]?
ParameterAttribute paramAttrib = paramInfo.GetCustomAttributes(false).OfType<ParameterAttribute>().Single();
//string paramName = "?" + paramAttrib.Name; //eg. '?param1' MYSQL
string paramName = ":" + paramAttrib.Name; //eg. '?param1' PostgreSQL
paramNames.Add(paramName);
System.Data.ParameterDirection direction = GetDirection(paramInfo, paramAttrib);
//MySqlDbType dbType = MySqlTypeConversions.ParseType(paramAttrib.DbType);
IDbDataParameter cmdParam = command.CreateParameter();
cmdParam.ParameterName = paramName;
//cmdParam.Direction = System.Data.ParameterDirection.Input;
if (direction == ParameterDirection.Input || direction == ParameterDirection.InputOutput)
{
object inputValue = inputValues[currInputIndex++];
cmdParam.Value = inputValue;
}
else
{
cmdParam.Value = null;
}
cmdParam.Direction = direction;
command.Parameters.Add(cmdParam);
}
if (!functionAttrib.IsComposable)
{
//procedures: under the hood, this seems to prepend 'CALL '
command.CommandType = System.Data.CommandType.StoredProcedure;
}
else
{
//functions: 'SELECT myFunction()' or 'SELECT hello(?s)'
string cmdText = "SELECT " + command.CommandText + "($args)";
cmdText = cmdText.Replace("$args", string.Join(",", paramNames.ToArray()));
command.CommandText = cmdText;
}
if (method.ReturnType == typeof(DataSet))
{
//unknown shape of resultset:
System.Data.DataSet dataSet = new DataSet();
IDbDataAdapter adapter = CreateDataAdapter(context);
adapter.SelectCommand = command;
adapter.Fill(dataSet);
List<object> outParamValues = CopyOutParams(paramInfos, command.Parameters);
return new ProcedureResult(dataSet, outParamValues.ToArray());
}
else
{
object obj = command.ExecuteScalar();
List<object> outParamValues = CopyOutParams(paramInfos, command.Parameters);
return new ProcedureResult(obj, outParamValues.ToArray());
}
}
}
static ParameterDirection GetDirection(ParameterInfo paramInfo, ParameterAttribute paramAttrib)
{
//strange hack to determine what's a ref, out parameter:
//http://lists.ximian.com/pipermain/mono-list/2003-March/012751.html
bool hasAmpersand = paramInfo.ParameterType.FullName.Contains('&');
if (paramInfo.IsOut)
return ParameterDirection.Output;
if (hasAmpersand)
return ParameterDirection.InputOutput;
return ParameterDirection.Input;
}
/// <summary>
/// Collect all Out or InOut param values, casting them to the correct .net type.
/// </summary>
static List<object> CopyOutParams(ParameterInfo[] paramInfos, IDataParameterCollection paramSet)
{
List<object> outParamValues = new List<object>();
//Type type_t = typeof(T);
int i = -1;
foreach (IDbDataParameter param in paramSet)
{
i++;
if (param.Direction == ParameterDirection.Input)
{
outParamValues.Add("unused");
continue;
}
object val = param.Value;
Type desired_type = paramInfos[i].ParameterType;
if (desired_type.Name.EndsWith("&"))
{
//for ref and out parameters, we need to tweak ref types, e.g.
// "System.Int32&, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
string fullName1 = desired_type.AssemblyQualifiedName;
string fullName2 = fullName1.Replace("&", "");
desired_type = Type.GetType(fullName2);
}
try
{
//fi.SetValue(t, val); //fails with 'System.Decimal cannot be converted to Int32'
//DbLinq.util.FieldUtils.SetObjectIdField(t, fi, val);
//object val2 = DbLinq.Util.FieldUtils.CastValue(val, desired_type);
object val2 = TypeConvert.To(val, desired_type);
outParamValues.Add(val2);
}
catch (Exception ex)
{
//fails with 'System.Decimal cannot be converted to Int32'
Console.WriteLine("CopyOutParams ERROR L245: failed on CastValue(): " + ex.Message);
}
}
return outParamValues;
}
}
}

View File

@@ -0,0 +1,56 @@
#region MIT license
//
// MIT license
//
// Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System.Data;
#if MONO_STRICT
using System.Data.Linq;
#else
using DbLinq.Data.Linq;
#endif
namespace DbLinq.MySql
{
#if !MONO_STRICT
public
#endif
class MySqlDataContext : DataContext
{
#if MYSQL_IS_REFERENCED
public MySqlDataContext(string connStr)
: base(new MySql.Data.MySqlClient.MySqlConnection(connStr), new MySqlVendor())
{
}
#endif
public MySqlDataContext(IDbConnection conn)
#if MONO_STRICT
: base(conn)
#else
: base(conn, new MySqlVendor())
#endif
{
}
}
}

Some files were not shown because too many files have changed in this diff Show More