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 7171285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:23:02+00:00 2026-05-28T15:23:02+00:00

I have a function that (via ajax) I pass a Guid and a comma

  • 0

I have a function that (via ajax) I pass a Guid and a comma delimited string of the types of objects I would like to return . I’m having trouble building a link statement that only returns the desired types. I’m struggling with how to build the query to check if string[] relatedTypes matches rw.GetType().Name. Or perhaps there’s a better way.

Here’s the Model…

public abstract class WebObject : IValidatableObject
{
    public WebObject()
    {
        this.Id = Guid.NewGuid();
        RelatedTags = new List<Tag>();
        RelatedWebObjects = new List<WebObject>();
    }

    [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
    public Guid Id { get; set; }
    public virtual ICollection<WebObject> RelatedWebObjects { get; set; }
    public IList<Guid> RelatedWebObjectIds { get; set; }
}

And here’s my function

public JsonResult GetRelatedWebObjectsByWebObject(Guid id, string relatedWebObjectTypes)
{
    JsonResult result = new JsonResult();
    Guid webSiteId = db.WebObjects.Find(id).WebSiteId;
    string[] relatedTypes = relatedWebObjectTypes.Split(',');
    var resultData = (from w in db.WebObjects
                      where w.Id == id
                      from rw in w.RelatedWebObjects
                      where rw.GetType().Name.Contains(relatedTypes)
                      select rw.Id).ToList();

    result.Data = resultData;
    result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
    return result;
}
  • 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-05-28T15:23:03+00:00Added an answer on May 28, 2026 at 3:23 pm

    A little late, but here’s what I ended up going with…

    public JsonResult GetRelatedWebObjectsByWebObject(Guid id, string relatedWebObjectTypes)
        {
            JsonResult result = new JsonResult();
            Guid webSiteId = db.WebObjects.Find(id).WebSiteId;
    
            List<string> relatedTypes = new List<string>(relatedWebObjectTypes.Split(','));
            var resultData = (from w in db.WebObjects
                              where w.Id == id
                              from rw in w.RelatedWebObjects
                              select rw).ToList();
    
            result.Data = resultData.Where(w => relatedTypes.Contains(w.GetType().BaseType.Name) == true).Select(w => new { Id = w.Id, Type = w.GetType().BaseType.Name }).ToList();//w.Id).Select(w => w.GetType().BaseType.Name).ToList();
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return result;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that issues an AJAX call (via jQuery). In the complete
I have a function that searches a database table via ajax. This is the
I have a function that updates a <div /> via AJAX: function update() {
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I would like to write a JavaScript function that validates a zip code, by
I have several tabs that are loaded via ajax, and each one has a
I have a form on my jQuery Mobile site that I would like to
I have a table that is passed via ajax and displayed. When the code
I have a javascript function that is called onsubmit: function formCheck(){ return usernameCheck() &&
i have this jquery function that i want to pass topic parameter to, i

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.