Note that there are some explanatory texts on larger screens.

plurals
  1. POCascade Saves with Fluent NHibernate AutoMapping - Old Answer Still Valid?
    primarykey
    data
    text
    <p>I want to do exactly what this question asks: <a href="https://stackoverflow.com/questions/586888/cascade-saves-with-fluent-nhibernate-automapping">Cascade Saves with Fluent NHibernate AutoMapping</a></p> <p>Using Fluent Nhibernate Mappings to turn on "cascade" globally once for all classes and relation types using one call rather than setting it for each mapping individually. </p> <p>The answer to the earlier question looks great, but I'm afraid that the Fluent Nhibernate API altered its .WithConvention syntax last year and broke the answer... either that or I'm missing something. </p> <p>I keep getting a bunch of name space not found errors relating to the IOneToOnePart, IManyToOnePart and all their variations: </p> <p>"The type or namespace name 'IOneToOnePart' could not be found (are you missing a using directive or an assembly reference?)"</p> <p>I've tried the official example dll's, the RTM dll's and the latest build and none of them seem to make VS 2008 see the required namespace.</p> <p>The second problem is that I want to use the class with my AutoPersistenceModel but I'm not sure where to this line: .ConventionDiscovery.AddFromAssemblyOf() in my factory creation method. </p> <pre><code> private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(SQLiteConfiguration.Standard.UsingFile(DbFile)) .Mappings(m =&gt; m.AutoMappings .Add(AutoMap.AssemblyOf&lt;Shelf&gt;(type =&gt; type.Namespace.EndsWith("Entities")) .Override&lt;Shelf&gt;(map =&gt; { map.HasManyToMany(x =&gt; x.Products).Cascade.All(); }) ) )//emd mappings .ExposeConfiguration(BuildSchema) .BuildSessionFactory();//finalizes the whole thing to send back. } </code></pre> <p>Below is the class and using statements I'm trying </p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using FluentNHibernate.Conventions; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using FluentNHibernate.Mapping; namespace TestCode { public class CascadeAll : IHasOneConvention, IHasManyConvention, IReferenceConvention { public bool Accept(IOneToOnePart target) { return true; } public void Apply(IOneToOnePart target) { target.Cascade.All(); } public bool Accept(IOneToManyPart target) { return true; } public void Apply(IOneToManyPart target) { target.Cascade.All(); } public bool Accept(IManyToOnePart target) { return true; } public void Apply(IManyToOnePart target) { target.Cascade.All(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload