learning
learning

Reputation: 11725

linq member has no supported translation to SQL

Upon running the query I have the following error:

System.NotSupportedException : The member 'Application.Product.IsValid' has no supported translation to SQL.

What is wrong with the following query?

Part of product class:

public Boolean IsValid
    {
        get { return this.isValid; }
        set
        {
            isValid = value;
        }
    }

I have a query as follows:

 Table<Product> Producttable = dataContext.GetTable<Product>();
            Table<ClientProduct> ClientProducttable = dataContext.GetTable<ClientProduct>();

 var query =
                from product in Producttable where product.IsValid == true
                join clientProduct in ClientProducttable
                on product.ID equals clientProduct.ProductID
                where clientProduct.ClientID == clientID 
                orderby product.Name ascending
                select product;

I also get the same error if I do

Table<Product> table = dataContext.GetTable<Product>();

        IQueryable<Product> query =
            from row in table
            where row.IsValid == false
            select row;

        return query.ToList<Product>();

Upvotes: 2

Views: 4341

Answers (1)

AgentFire
AgentFire

Reputation: 9790

Mark your Isvalid property with Column attribute.

I believe, the Linq-to-sql engine needs to have a column attribute in order to look up the database table. As well as its parameters (of the attribute), like ColumnName or alike.

Upvotes: 2

Related Questions