WithCascadeDelete Not Available

5 posts, 1 answers
  1. Michel
    Michel avatar
    2 posts
    Member since:
    Sep 2013

    Posted 12 Sep 2013 Link to this post

    Hi!

    I am using ORM version 2013.2.702.1 and ASP.NET MVC 4.5. I am trying to use WithCascadeDelete like the documentation: Cascade Delete on Class Level, but the method is not available:

    using FluentModel.Entity;
    using Telerik.OpenAccess.Metadata;
    using Telerik.OpenAccess.Metadata.Fluent;
     
    namespace FluentModel.Map
    {
        public class ProdutoMap
        {
            public static MappingConfiguration<Produto> CreateConfiguration()
            {
                var produtoMapping = new MappingConfiguration<Produto>();
     
                produtoMapping.MapType(p => new
                {
                    p.Id,
                    p.Nome,
                    p.Preco,
                    p.Descricao,
                    p.DataCadastro
     
                }).ToTable("produto");
     
                produtoMapping.HasProperty(p => p.Id).IsIdentity(KeyGenerator.Autoinc);
                produtoMapping.HasProperty(p => p.Nome).HasLength(60);
                produtoMapping.HasProperty(p => p.Preco).IsCurrency();
                produtoMapping.HasProperty(p => p.Descricao).HasLength(60);
     
                produtoMapping.HasAssociation(p => p.Categoria)
                           .WithOpposite(c => c.Produtos)
                           .HasConstraint((p, c) => p.CategoriaId == c.Id)
                           .ToColumn("Categoria_id");
                 
     
                return produtoMapping;
            }
        }
    }

    If I try to use:
    produtoMapping.MapType().WithCascadeDelete()

    The compiler cannot resolve the method.

    Do you have any Idea why?

    Best regards.

  2. Chom
    Chom avatar
    56 posts
    Member since:
    Dec 2009

    Posted 16 Sep 2013 Link to this post

    I have the same problem...

    AllowCascadeDelete will not resolve in my fluent context model.

    public static BackendConfiguration GetBackendConfiguration()

    {

    BackendConfiguration backend = new BackendConfiguration();

    backend.Runtime.AllowCascadeDelete = true;

    backend.Backend = "SqlCe";

    backend.ProviderName = "Microsoft.SqlServerCe.Client.3.5";

    return backend;

    }

    Still trying to find a solution

    chom

  3. DevCraft banner
  4. Answer
    Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 17 Sep 2013 Link to this post

    Hi Michael and Chom,

    Excuse us for the inconvenience caused and thank you for pointing us to this inconsistency in our documentation. 

    Indeed, the Q2 2013 SP1 version of OpenAccess ORM does not support the AllowCascadeDelete property and the WithCascadeDelete() method because they are implemented as part of a feature which will be released with the internal build scheduled for the end of this week.

    Currently, the article in question is temporarily unavailable and will be live again once the internal build is officially downloadable. Additionally, I will make sure you are notified for the release in this thread.

    Thank you for your understanding. If you have further questions or experience issues, do not hesitate to get back to us.


    Regards,
    Doroteya
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  5. Michel
    Michel avatar
    2 posts
    Member since:
    Sep 2013

    Posted 17 Sep 2013 Link to this post

    Hi Chom!

    Maybe using the method IsDependent() in your mapping class like bellow helps you.

    produtoMapping.HasAssociation(p => p.Categoria)
                           .WithOpposite(c => c.Produtos)
                           .HasConstraint((p, c) => p.CategoriaId == c.Id)
                           .IsDependent()
                           .ToColumn("Categoria_id");

    Best regards
    Michel Andrade





  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 19 Sep 2013 Link to this post

    Hello,

    This setting is now available in the 2013 Q3 Beta version of OpenAccess which has been released yesterday.

    However, please note that the AllowCascadeDelete option applies only to persistent classes which are mapped to more than one table - this is valid for vertically mapped derived types or multi-table entities. If you would like to delete an object and its related ones (via a foreign key or M:N association), please use the IsDependent() fluent mapping method, as Michel suggested.

    Regards,
    Alexander
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top
DevCraft banner