बनाने नहीं मैं, दो टेबल, स्थानों और सुविधाएंधाराप्रवाह NHibernate Automapping बहुवचन तालिका नाम
वे दो वर्गों के लिए नक्शे,
public Location : Entity
{
//properties
}
public Facility : Entity
{
public virtual Location Location { get; set; }
}
सब कुछ बस dandy काम करता है जब तक मैं इस
की सुविधा बदलpublic Facility : Location
{
}
अब मैं nHibernate से एक अपवाद कह
NHibernate.ADOException was unhandled by user code
Message=could not execute query
InnerException: System.Data.SqlClient.SqlException
Message=Invalid object name 'Facility'.
प्राप्त
किसी कारण से यह एसक्यूएल स्ट्रिंग में तालिका का बहुवचन नाम नहीं बना रहा है।
किसी भी मदद के लिए धन्यवाद!
संपादित
यह मेरे वर्तमान TableNameConvention
public class TableNameConvention : IClassConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
{
instance.Table(Inflector.Net.Inflector.Pluralize(instance.EntityType.Name));
}
}
सुविधा इकाई से इनहेरिट करते हैं, तो सुविधा इस पद्धति के माध्यम से चलाने करता है। जब यह स्थान से विरासत, यह
public class AutoPersistenceModelGenerator : IAutoPersistenceModelGenerator
{
#region IAutoPersistenceModelGenerator Members
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings.AddEntityAssembly(typeof(Person).Assembly).Where(GetAutoMappingFilter);
mappings.Conventions.Setup(GetConventions());
mappings.Setup(GetSetup());
mappings.IgnoreBase<Entity>();
mappings.IgnoreBase(typeof(EntityWithTypedId<>));
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
return mappings;
}
#endregion
private Action<AutoMappingExpressions> GetSetup()
{
return c =>
{
c.FindIdentity = type => type.Name == "Id";
};
}
private Action<IConventionFinder> GetConventions()
{
return c =>
{
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.ForeignKeyConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.HasManyConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.HasManyToManyConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.ManyToManyTableNameConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.PrimaryKeyConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.ReferenceConvention>();
c.Add<BHP.DEC.Data.NHibernateMaps.Conventions.TableNameConvention>();
};
}
/// <summary>
/// Provides a filter for only including types which inherit from the IEntityWithTypedId interface.
/// </summary>
private bool GetAutoMappingFilter(Type t)
{
return t.GetInterfaces().Any(x =>
x.IsGenericType &&
x.GetGenericTypeDefinition() == typeof(IEntityWithTypedId<>));
}
}
फ्लुएंट एनएचबर्ननेट तालिका के नामों का कोई बहुवचन नहीं करता है, या उस मामले के लिए कुछ भी नहीं। आपको डेविड जैसे एक सम्मेलन को बनाने और वहां के नेट इन्फ्लेक्टरों में से एक का उपयोग करने की आवश्यकता है। –
तालिकानाम कॉन्फ़्रेंस वहां है, लेकिन किसी कारण से जब मैं स्थान से उत्तराधिकारी के लिए सुविधा बदलता हूं, तो जब यह असेंबली स्कैन करता है तो धाराप्रवाह सेटअप अब इसे नहीं ढूंढता है। –
जैसा कि, ऐसा लगता है कि आप स्थान को अन्य बेस क्लास के रूप में देख रहे हैं, इस मामले में निम्नलिखित कार्य कर सकते हैं: मैपिंग्स। इग्नोरबेस(); या किसी टेबल-प्रति-सबक्लास की तरह कुछ के लिए जा रहे हैं? –
David