Only initializers, entities, and entity navigation properties are supported. (ASP.NET MVC and Entity Framework)

I am stuck somewhere in my ASP.NET MVC 3 application. Here is the error I get:

The specified member of type 'AccommPropertyTags' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

I found how we can solve this in the following article:

Only initializers, entities, and entity navigation properties are supported.

But mine is a little strange.

Here is one of the partial class of my object:

[MetadataType(typeof(AccommPropertyWebDetail.MetaData))]
public partial class AccommPropertyWebDetail {

    public virtual ICollection<string> AccommPropertyTags {

        get {

            return Helpers.AccommPropertyTag.CreateStringListFromString(this.PropertyTags);
        }
    }

    private class MetaData {

        [Required, StringLength(50)]
        public string Category { get; set; }

    }
}

As you can see above, the property AccommPropertyTagsis typeof ICollection<string>. In my controller, I am trying to do the following:

public ViewResult Tag(string tag) {

    var _rawTag = HttpUtility.UrlDecode(tag);

    ViewBag.Tag = _rawTag;

    var model = _accommpropertyrepo.GetAllAccommPropertiesFullWebIgnoringApprovalStatus();

    model = model.Where(
            x => x.AccommPropertyTags.Any(
                    y => y == _rawTag
                )
        );

    return View(model);
}

- , Any , Entity AccommPropertyTags SQL , .

?

+5
1

, . model.ToList() Where. EF , .

public ViewResult Tag(string tag) {

    var _rawTag = HttpUtility.UrlDecode(tag);

    ViewBag.Tag = _rawTag;

    var model = _accommpropertyrepo.GetAllAccommPropertiesFullWebIgnoringApprovalStatus();

    var result = model.ToList().Where(
            x => x.AccommPropertyTags.Any(
                    y => y == _rawTag
                )
        );

    return View(result);
}
+10

All Articles