views:

496

answers:

2

Hello,

I just started learning Nhibernate and Fluent Nhibernate. I want to specify table name when I create my mapping class.

Entity name in application is "CustomerOrders" but in the oracle database, table name is "CUSTOMER_ORDERS".

I learnt from googling that I can use "WithTable" to specify database table name.

I am not sure how to use it and where as Vs2008 didn't find the method.

Thanks

+2  A: 
public class CustomerOrdersMap : IAutoMappingOverride<CustomerOrders>
    {
        public void Override(AutoMapping<CustomerOrders> mapping)
        {
            mapping.Table("CUSTOMER_ORDERS");


        }
    }
dove
@Thakkar i'm not sure from question how much more you would need specifically, so just ask if you want more context
dove
Dove, Table names and field names contains underscores and I do not have underscores in any entity class name or properties. I am not using AutoMapping because of these reason. I am extending from ClassMap manually. Now, is there a way to map field names as well with AutoMapping or map to a table name using ClassMap? Please advise.
AlterWorld
@Thakkar is there a convention of any kind between properties and table names. if it was consistant in some way, a convention could be written for it. for example all my foreign key names have FK as suffix in my databases.
dove
Dove, field names do not have any name patterns. The underscores appear randomly.e.g. Table name: Customer_OrdersField names: ID, Order_ID, Order_Item_ID, Item_Info, Comments, etc..Unfortunately, I cannot change the database as other existing systems are using it. I see a "Table" method in the FluentNHibernate.Mapping.ClassMap. Do you think It will map the class to appropriate table?
AlterWorld
+1  A: 

WithTable was renamed to Table for the 1.0 release. It was mentioned in the release notes (first bullet point).

James Gregory