This is a migrated thread and some comments may be shown as answers.

WithCascadeDelete Not Available

4 Answers 62 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michel
Top achievements
Rank 2
Michel asked on 12 Sep 2013, 10:37 PM
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.

4 Answers, 1 is accepted

Sort by
0
Chom
Top achievements
Rank 1
answered on 16 Sep 2013, 04:00 PM
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

0
Accepted
Doroteya
Telerik team
answered on 17 Sep 2013, 07:33 PM
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.
0
Michel
Top achievements
Rank 2
answered on 17 Sep 2013, 07:46 PM
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





0
Alexander
Telerik team
answered on 19 Sep 2013, 01:15 PM
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.
Tags
Development (API, general questions)
Asked by
Michel
Top achievements
Rank 2
Answers by
Chom
Top achievements
Rank 1
Doroteya
Telerik team
Michel
Top achievements
Rank 2
Alexander
Telerik team
Share this question
or