nhibernate - Join between two non-key fields -


I am working to connect a simple POC app using Fluent NBibernate so that it can show that it In our present hand everything can be controlled Data Access Tool and so much more than one of the fringe cases which is concerned about my boss, a query has the ability to reach many schemas within the same database. So far, I have been able to draw data from the tables in both schemas, as long as the query touches only one schema at a time. If I try to execute an order which will join tables in schema, then it runs up

I see that depending on the error message, I do not believe the problem is in the schema With the joining, the fact is that in both the areas I need to join tables. The structure of the non-major two table is something like this:

 Customer (in Schema 1) --- ----- complete S customer ID (primary key) string name ... other field order (in schema 2) -------- ing (primary key) string customer name ... other fields 

sql By using directly I could join names / customer name areas and get data from both tables. However, using the NHibernate, I was "System.FormatException: Input String was not in a correct format" when trying to draw data from the order table and include data from the customer table. From this I believe that NHibernate is trying to join the Customer Name field and Customer ID field.

I know how it asks me to use the Customer Name field in my order mapping, but I can not understand a way to tell the customer to join the name field of the table.

My mappings look something like this:

  Public class CustomerMap: Classmap & lt; Customers & gt; {PUBLIC CUSTOMMAP () {ID (x = & gt; x.Id). Columns ("Customer ID"); Map (x = & x; x.Name); }} Public class ordermax: class mark & ​​lt; Order & gt; {Public ordermap (schema) (schema ("schema 2"); ID (x => x.Id). Column ("order id"); Map (x = & gt; x.CustomerName) Columns ("Customer Name"); Reference & lt; Customers & gt; (X = & gt; x.Customer, "Customer Name"); }}  

The SQL I would like to write to get the results that I want to do is something like this:

  oordind, o Select CustomerName, C. Order from CustomerId and Join Internal Clients c.Name = o.CustomerName  

Is this possible? Is there a different / better way to go about this?

I have not worked with many schemas, but to map non-main fields, By way of way, it is as follows:

In order mark ... reference (order => order customer). Columns ("Customer Name"). Compressed ("name");

Where propertyRef ("name") is actually referring to the name property on your client class (which you will define in customermap).

I'm just starting with FHH, you can get a better solution, but I hope that it will be helpful.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -