예제 #1
0
        public void AddDelete(ClrClass @class, DbTable table)
        {
            if (@class == null)
            {
                throw new ArgumentNullException("class");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            var varName = NameProvider.ToParameterName(@class.Name);

            _buffer.AppendLine(string.Format(@"public void Delete({0} {1})", @class.Name, varName));

            this.BeginBlock();

            _buffer.AppendLine(this.GetParameterCheck(varName));
            this.AddEmptyLine();

            _buffer.AppendLine(string.Format(@"var query = @""{0}"";", QueryCreator.GetDelete(table).Statement));
            this.AddEmptyLine();
            _buffer.AppendLine(@"var sqlParams = new []");

            this.BeginBlock();
            _buffer.AppendLine(string.Format(@"QueryHelper.Parameter(@""{0}"", {1}.{0}),", NameProvider.IdName, varName));
            this.EndBlockWith();

            this.AddEmptyLine();

            _buffer.AppendLine(@"QueryHelper.ExecuteQuery(query, sqlParams);");

            this.EndBlock();
        }