public static void ImportSqlObject(string name, Server server, IModularDbClient dbClient)
        {
            string filename = "";

            if (dbClient.GetRecordScalar <int>(null, server.ConnectionContext.ConnectionString, new RepositoryMethodDefinition($"SELECT OBJECT_ID('{name}')", CommandType.Text, null, null, null)) < 1)
            {
                if (name.StartsWith("dbo.sp_", StringComparison.InvariantCultureIgnoreCase))
                {
                    filename = $"../SqlSchema/StoredProcedure/{name}.SQL";
                }
                else if (name.StartsWith("dbo.vw", StringComparison.InvariantCultureIgnoreCase))
                {
                    filename = $"../SqlSchema/View/{name}.SQL";
                }
                else
                {
                    filename = $"../SqlSchema/Table/{name}.SQL";
                }

                string initScript = File.ReadAllText(filename);

                Console.WriteLine($"Executing SQL script '{filename}'");

                server.ConnectionContext.ExecuteNonQuery(initScript);
            }
        }
Example #2
0
        protected internal TReturn GetRecordScalar <TReturn>(TUser objSearch, string definitionName)
        {
            var def = GetDefinition(definitionName);

            if (def == null)
            {
                throw new ArgumentException($"No repository definition found named \"{definitionName}\"", nameof(definitionName));
            }



            return(_dbClient.GetRecordScalar <TReturn>(objSearch, ConnectionString, def));
        }