Exemple #1
0
        public SqlPreCommand DeleteSqlSync(IdentifiableEntity ident, string comment = null)
        {
            var pre = OnPreDeleteSqlSync(ident);
            var collections = (from m in this.Fields
                               let ml = m.Value.Field as FieldMList
                               where ml != null
                               select new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                                   .Formato(ml.TableMList.Name, ml.TableMList.BackReference.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()))).Combine(Spacing.Simple);

            var main = new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                    .Formato(Name, "Id", ident.Id, comment ?? ident.ToString()));

            return SqlPreCommand.Combine(Spacing.Simple, pre, collections, main);
        }