Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8392727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:35:24+00:00 2026-06-09T19:35:24+00:00

I have a class ApprovalTicket that has a property called ApprovalRules that is of

  • 0

I have a class ApprovalTicket that has a property called ApprovalRules that is of type IApproval:

IApproval ApprovalRules;

This field will contain several different types of classes that implement that interface. Now stepping one level up, I will have a List of ApprovalTickets. What I’m trying to do is use linq to return a list of ApprovalTickets that have ApprovalRules of the type MocReviewerApproval.

I was trying something like:

var reviews = request.MocApprovalTasks
  .Where(mocApproval => mocApproval.ApprovalRules is MocReviewerApproval)
  .ToList();

But when I check the list that gets returned, it’s still including tickets that have an ApprovalRules type of MocManagerApproval and others as well. What am I missing?

UPDATE:

Let me be more specific. Here is the inheritance scheme

MocApproval : TaskTicket
    >>IApproval ApprovalRules;

MocReviewerApproval : IApproval
MocManagerApproval : IApproval
MocControllerApproval : IApproval


    internal interface IApproval
    {
        bool Approve(Guid approverGuid, MocApproval approval);
        bool Deny(Guid approverGuid, MocApproval approval, TaskComment denialComment);
        bool Close(Guid approverGuid, MocApproval approval, TaskComment closeComment);
        bool Notify();
        void Set(MocApproval approval);
        User GetAssignee();
        TaskComment GetNotificationComment();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:35:26+00:00Added an answer on June 9, 2026 at 7:35 pm

    Your code looks fine to me. I suspect you’ve got diagnostic problems, or you’re not after the is kind of relationship at all. Here’s a complete example showing it working:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    
    class Foo
    {
        public object Value { get; set; }
    }
    
    class Test
    {
        static void Main()
        {
            var list = new List<Foo>
            {
                new Foo { Value = "" },
                new Foo { Value = 10 },
                new Foo { Value = new object() },
                new Foo { Value = new MemoryStream() }
            };
    
            ShowCount<IDisposable>(list); // 1 (MemoryStream)
            ShowCount<IFormattable>(list); // 1 (Int32)
            ShowCount<IComparable>(list); // 1 (String, Int32)
        }
    
        static void ShowCount<T>(List<Foo> list)
        {
            var matches = list.Where(f => f.Value is T)
                              .ToList();
            Console.WriteLine("{0} matches for {1}", 
                              matches.Count, typeof(T));
        }
    }
    

    EDIT: If you want matches which are exactly the given type, use:

    var reviews = request.MocApprovalTasks
                         .Where(task => task.ApprovalRules.GetType() == 
                                               typeof(MocReviewerApproval))
                         .ToList();
    

    That’s more refactoring-friendly than finding the name as per Servy’s original answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class B that has class A, this is simplified version of class
I have class A that has some primitive attributes and also member of type
I have class that looks like this: class A { public: class variables_map vm
I have class class DateOptTimeType implements org.hibernate.usertype.UserType that works with two columns @org.hibernate.annotations.Type(type =
I have class User that contains protected constructor and class Account that has access
I have class which has a method that needs to return three DataTables. I
I have class that applies a dotted style border property to a text block
I have class, that has a NSString. @interface AudioManager : NSObject { AudioData *data_;
I have class (MyCustomWebView) that extend webview can i do something like this ?
I have Class CustomDate and that is referred in other class called Test. public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.