I have a table containing service announcements. For this table, I have POCO 1: 1, except that it contains one additional field. In my query, this is combined in the author’s username, the table contains only the author’s identifier.
I thought I could just apply the attribute [Ignore]in this field and then use POCO to insert / update without problems? My problem is that the [Ignore]field is BrukerNavnnot populated with the attribute . And without an attribute, it spoils on insert / update.
[TableName("tblDriftsmelding")]
[PrimaryKey("DriftID")]
public class Driftsmelding
{
public int DriftID { get; set; }
[Column("tittel")] public string Tittel { get; set; }
public string Tekst { get; set; }
public string HTMLTekst { get; set; }
[Column("gyldigfra")] public DateTime? Fra { get; set; }
[Column("gyldigtil")] public DateTime? Til { get; set; }
[Column("publisert")] public bool Publisert { get; set; }
[Column("CreatedBy")] public int? BrukerID { get; set; }
public string BrukerNavn { get; set; }
}
This is POCO. The table is a 1: 1 display, with the exception of the “BrukerNavn” field at the end.
select d.DriftID, d.Tekst, d.Created, d.gyldigtil, d.gyldigfra, d.publisert, d.tittel, d.HTMLTekst, d.createdby, b.brukerident as BrukerNavn
from tblDriftsmelding d
left outer join tblbruker b on d.CreatedBy = b.brukerid
order by DriftID desc
This is a request that POCO sends. (I also tried to use select d.*, b.brukerid. No difference)
( , , - )