timbered wrote:
I'm trying it now with the generated code, and it seems to work. I read an address, and the State entity is there.
So, I'm even more confused now.
This isn't fetching a collection. As far as the database is designed, I have a FK inside my Address table that points to the key (a single key) of my States table. So, I can change / lookup (sorry, I'm in the USA and using that as an example) "CA" (address table) to "California" (State table).
My Address entity has a Ship To address and a Bill To Address. So, two state abbreviations. But each gets a single State entity, with the state name inside it.
All I want to do is have an Address entity, and find the State Name in the State table. State isn't a collection. Nor do I ever want to read a State and get a collection of Addresses.
That's is pretty basic RDBMS stuff, isn't it? Mind you, I'm new to ORM, but still.
Yes, and this is OK. The lazy loading from FK to PK is fine, as it uses a lambda using the PK fetch.
So in Address you have an FK to state which is the PK side of the relationship, and the lazy loading for the state entity from the address entity will use e=>e.FetchUsingPK(statePk) where 'e' is the state entity class instance. So that's ok.
If you want to go the other way around, it's not ok. You don't need that, that's fine, but fetching the 'many' side of the relationship fails. The warning is there to let you know that that can happen. You won't run into the side effect as you're not planning to go from state to address, so you can decide to hide the warning if you want. It won't affect your code. That's also why it's a warning: things could go wrong in your code if you want to use the pk -> fk side of the relationship in a lazy loading scenario and you should be aware of that hence the warning and not an error, as things will work fine from the other side of the relationship.
Then how do I do this with Selfservicing? I don't think there's anything esoteric about what I'm trying to do, but it's quite possible part of my brain is still stuck at the non-ORM database table level and I'm not grasping a concept correctly.
And if it's not possible with Selfservicing, why would it then work with Adapter? What's the difference in this specific case that Adapter would work with no reference from State to Address?
What you're doing is perfectly fine, the warning is there to let you know that if you hide one navigator it might be you run into a problem with selfservicing's lazy loading code. You can always fetch data even if there are no navigators, e.g. through linq or queryspec or using the low level API where you new up a collection instance and use GetMulti().
So in short: don't worry about it