最终,我确实找到了一个很好的解决方案。答案是简单地使LINQ to sql成为可能。像这样:
using (MyDataContext context = CreateDataContext())
{
// Set the load options for the query (these tell LINQ that the
// Datanode object will have an associated DataObject object just
// as before).
context.LoadOptions = StaticLoadOptions;
// Run a plain old sql query on our context. LINQ will use the
// results to populate the node object (including its DataObject
// property, thanks to the load options).
Datanode node = context.ExecuteQuery<Datanode>(
"SELECT * FROM Node INNER JOIN Object " +
"ON Node.ObjectId = Object.ObjectId " +
"WHERE ObjectId = @p0",
objectId).FirstOrDefault();
//...
}