开发者

What return value to use to match two different kinds of Types

开发者 https://www.devze.com 2023-03-14 14:29 出处:网络
I\'m using LINQ towards my MSSQL database. I have the TypeOfMetaData-table, the UserMetaData-table and the MetaDataHasType-table that has foreign-keys from the TypeOfMetaData- and the UserMetaData-tab

I'm using LINQ towards my MSSQL database. I have the TypeOfMetaData-table, the UserMetaData-table and the MetaDataHasType-table that has foreign-keys from the TypeOfMetaData- and the UserMetaData-table. What I need to do a method to get all MetaData and Types and return them. The problem is that I don't know what kind of return value I should use to be able to match the correct rows together.

开发者_如何学Go

Thanks for the help,

wardh


You could use an Anonymous Type (var) to store the result:

var result = 
  yourDataContext
  .UserMetaData_Table
  .Select(
    userMetaData => 
      new
      {
         UserMetaData = userMetaData,
         Types = userMetaData.MetaDataHasTypes.Select(types => types.TypeOfMetaData),
      })
  .ToArray();

If this isn't what you want, could you update you question to with an example of the data context and the classes you have and what you have tried so far.

0

精彩评论

暂无评论...
验证码 换一张
取 消