Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ, entity that implements Interface and exception in mapping
    primarykey
    data
    text
    <p>I'm using repository pattern with LINQ, have IRepository.DeleteOnSubmit(T Entity). It works fine, but when my entity class has interface, like this: </p> <pre><code>public interface IEntity { int ID {get;set;} } public partial class MyEntity: IEntity { public int ID { get { return this.IDfield; } set { this.IDfield=value; } } } </code></pre> <p>and then trying to delete some entity like this: </p> <pre><code>IEntity ie=repository.GetByID(1); repoitory.DeleteOnSubmit(ie); </code></pre> <p>throws<br> The member 'IEntity.ID' has no supported translation to SQL. </p> <p>fetching data from DB works, but delete and insert doesn't. How to use interface against DataContext?</p> <hr> <p>Here it is:<br> Exception message: The member 'MMRI.DAL.ITag.idContent' has no supported translation to SQL. </p> <p>Code: </p> <pre><code>var d = repContent.GetAll().Where(x =&gt; x.idContent.Equals(idContent)); foreach (var tagConnect in d) &lt;- error line { repContet.DeleteOnSubmit(tagConnect); </code></pre> <p>(it gets all tags from DB, and deletes them)</p> <p>And stack trace: </p> <pre><code>[NotSupportedException: The member 'MMRI.DAL.ITag.idContent' has no supported translation to SQL.] System.Data.Linq.SqlClient.Visitor.VisitMember(SqlMember m) +621763 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +541 System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitBinaryOperator(SqlBinary bo) +18 System.Data.Linq.SqlClient.Visitor.VisitBinaryOperator(SqlBinary bo) +18 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +196 System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) +8 System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) +46 System.Data.Linq.SqlClient.Visitor.VisitSelect(SqlSelect select) +20 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) +1024 System.Data.Linq.SqlClient.SqlProvider.BuildQuery( ... </code></pre> <p>When I try do decorate partial class:</p> <pre><code>[Column(Storage = "_idEvent", DbType = "Int NOT NULL", IsPrimaryKey = true)] public int idContent { get { return this.idEvent; } set { this.idEvent=value; } } </code></pre> <p>it throws error "Invalid column name 'idContent'."</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload