Пример #1
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IClientFactory clientFactory,
                                                                           WriteStoredProcedure storedProcedure)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var client = clientFactory.GetClient();

            var query = string.Format(GetStoredProcedureParamsQuery, "testdata", storedProcedure.SchemaName,
                                      storedProcedure.SpecificName);
            var results = await client.ExecuteReaderAsync(query);

            foreach (var row in results)
            {
                var property = new Property()
                {
                    Id           = row[ParamName].ToString(),
                    Name         = row[ParamName].ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(row[DataType].ToString()),
                    TypeAtSource = row[DataType].ToString()
                };

                schema.Properties.Add(property);
            }

            return(schema);
        }
Пример #2
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IConnectionFactory connFactory,
                                                                           WriteStoredProcedure storedProcedure, string goldenRecordIdParm)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var conn = connFactory.GetConnection();
            await conn.OpenAsync();

            var cmd = connFactory.GetCommand(
                string.Format(GetStoredProcedureParamsQuery, storedProcedure.SchemaName, storedProcedure.SpecificName),
                conn);
            var reader = await cmd.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                var property = new Property
                {
                    Id           = reader.GetValueById(ParamName).ToString(),
                    Name         = reader.GetValueById(ParamName).ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(reader.GetValueById(DataType).ToString()),
                    TypeAtSource = reader.GetValueById(DataType).ToString(),
                };

                // mark as key if the property is to map the golden record id
                if (!string.IsNullOrWhiteSpace(goldenRecordIdParm))
                {
                    if (property.Id == goldenRecordIdParm)
                    {
                        property.IsKey = true;
                    }
                }

                schema.Properties.Add(property);
            }

            await conn.CloseAsync();

            return(schema);
        }
Пример #3
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IConnectionFactory connFactory,
                                                                           WriteStoredProcedure storedProcedure)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var conn = connFactory.GetConnection();
            await conn.OpenAsync();

            var cmd = connFactory.GetCommand(
                string.Format(GetStoredProcedureParamsQuery, storedProcedure.SchemaName, storedProcedure.SpecificName),
                conn);
            var reader = await cmd.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                var property = new Property
                {
                    Id           = reader.GetValueById(ParamName).ToString(),
                    Name         = reader.GetValueById(ParamName).ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(reader.GetValueById(DataType).ToString()),
                    TypeAtSource = reader.GetValueById(DataType).ToString()
                };

                schema.Properties.Add(property);
            }

            await conn.CloseAsync();

            return(schema);
        }