私は基本クラスPosts
とを持っておりNotifications
、Notes
からPhotos
継承してPosts
います。Posts から継承されたすべてのオブジェクトを含む単一のリストを単一のList<Post>
.
var notes = posts.OfType<Note>();
var photos = posts.OfType<Photo>();
var notifications = posts.OfType<Notification>(); ;
return (from n in notes
select new Stream()
{
id = n.post_id,
value = n.value,
timestamp = n.timestamp,
type = "note"
}).ToList();
もちろん、上記はメモのみを返します。
前もって感謝します。