C# How i use linq with explicit interface attribute? -
i have 1 class 2 inheritance interfaces , yours attributes explicits because both have equals attributes, so, need use linq class, can't access explicits attributes when use "select new foo" ... case:
public class questaomontaprova : iquestao, iexercicio { public int discordo { get; set; } public int rever { get; set; } public int anotacao { get; set; } public int realizada { set; get; } public int ativo { set; get; } int iquestao.id { get; set; } string iquestao.enunciadoquestao { get; set; } string iquestao.exerciciotipo { get; set; }
....
and linq :
var flags = (from b in dt.asenumerable() select new questaomontaprova { idquestao = convert.toint32(b["id_questao"]), // can't access idtipoexercicio = convert.toint32(b["id_tipoexercicio"]),// can't access discordo = convert.toint32(b["discordo"]), rever = convert.toint32(b["rever"]), anotacao = convert.toint32(b["anotacao"]), realizada = convert.toint32(b["realizada"]), correta = convert.toint32(b["correta"]), ativo = convert.toint32(b["ativo"]) }).tolist();
if possible, implement interfaces implicitly instead of explicitly, servy suggested.
if won't work you, use method syntax portion instead of query syntax, can include multi-line delegate instead of single-expression one. lets cast access hidden properties.
var flags = dt.asenumerable().select(b => { var q = new questaomontaprova { discordo = convert.toint32(b["discordo"]), rever = convert.toint32(b["rever"]), anotacao = convert.toint32(b["anotacao"]), realizada = convert.toint32(b["realizada"]), correta = convert.toint32(b["correta"]), ativo = convert.toint32(b["ativo"]) }; var iq = (iquestao)q; iq.id = convert.toint32(b["id_questao"]); iq.exerciciotipo = convert.toint32(b["id_tipoexercicio"]); return q; }).tolist();
Comments
Post a Comment