In my project I've two Interesting database tables:
CREATE TABLE [dbo].[User]
(
[Id] INT NOT NULL IDENTITY,
[Name] NCHAR(60) NOT NULL,
PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Event]
(
[Id] INT NOT NULL PRIMARY KEY identity,
...
[User id] INT NULL,
CONSTRAINT [FK_Event_User] FOREIGN KEY ([User id]) REFERENCES [User](Id)
)
I want to have access to the Event's users in my Application which take data from WCF.
To make this possible I've to change Child Property
in User_Event Association
according to this answer.
I use LINQ SQL and I noticed that event.User
property is not null only when I invoke get properties on it.
Now I have to add for loop to force invoking this._User.Entity
, but it don't look like this solution...
public List<Event> GetAllEvents()
{
var ev = Database.Instance.Db.Events;
foreach (var v in ev)
{
User u = v.User;
}
return ev.ToList();
}