0

I have back-end where I need to get FIO from table

I try to write code and here is what I have

 public ActionResult Profile_Data_Questions()
    {
        var dataforprofile = TempData["FIO"];
        var profiledata = db.QuestionBlocks
            .Where(x => x.Interview.Interwiers == dataforprofile)

    }

But Interwiers is IColection

Here is Model for Interwiers

 [Key]
    public int Interwier_id { get; set; }
    [Display(Name = "ФИО")]
    public string FIO { get; set; }
    public string Email { get; set; }
    [Display(Name = "Телефон")]
    public string Telephone { get; set; }
    [Display(Name = "День рождения")]
    [DataType(DataType.Date)]
    public string Birthday { get; set; }
    [Display(Name = "Город")]
    public string City { get; set; }
    [Display(Name = "Зарплата")]
    public string Salary { get; set; }
    [Display(Name = "Английский")]
    public string English { get; set; }
    public Nullable<int> Interview_Id { get; set; }
    [Display(Name = "Статус")]
    public string Status { get; set; }

    public virtual Interview Interview { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<Link> Links { get; set; }

How I can get FIO property?

2 Answers2

1

i assume the dataforprofile is a string or an int / enum, ... you can search the items that have the prop set to dataforprofile.

var profiledata = db.QuestionBlocks
        .Where(x => x.Interview.Interwiers.Any(y=> y.prop == dataforprofile))

the code above will give you all questionblocks where there is an interview containing one or more interviewers with the prop set to the dataforprofile var.

Gelootn
  • 601
  • 6
  • 16
0

Heck I am not sure what your problem is, and I can't ask for clarification yet, due to not having accumulated enough rep. So here goes:

Either your collection does not contain interviewer objects, and you need to convert your request into the object type like so:

var targetList = origList
  .Select(x => new TargetType() { SomeValue = x.SomeValue })
  .ToList();

Or, if the question is even simpler I will link to another question that answers my other interpretation of your question:

How to expose a collection property?

Community
  • 1
  • 1
Morten Bork
  • 1,413
  • 11
  • 23