I tried in different ways to accomplish this but I can make it work I have a class called CampoConfiguracionVista
Defined like this
public class CampoConfiguracionVista
{
public CampoConfiguracionVista()
{
}
public int IDCampo { get; set; }
public int IDConfiguracion { get; set; }
public string Nombre { get; set; }
public bool ValidationEspecial { get; set; }
public bool Requerido { get; set; }
public int IDTipodato { get; set; }
public int? minimo { get; set; }
public int? maximo { get; set; }
public string[] valores { get; set; }
}
And I have linq where I have i field called Valores
which contains an string value separate by ;
So What to I want to Accomplish it's split this field value into a string array I tried in this two ways :
first: all in one linq
var query = (from T in db.ConfiguracionCampo
where T.IDTipificacion == idTipificacion
&& T.Campo.Activo == true
select new CampoConfiguracionVista()
{
IDCampo = T.Campo.IDCampo,
IDTipodato = T.IDTipodato,
ValidationEspecial = T.ValidationEspecial,
minimo = T.minimo,
maximo = T.minimo,
Requerido = T.Requerido,
Nombre = T.Campo.Nombre,
valores = T.Valores.Split(';')
}).ToList();
Second: I think that the problem was the linq can't translate the split to sql so i made two linqs like this *
var query = (from T in db.ConfiguracionCampo
where T.IDTipificacion == idTipificacion
&& T.Campo.Activo == true
select T);
var camposConfigurados = (from D in query select D).Select(C => new CampoConfiguracionVista()
{
IDCampo = C.Campo.IDCampo,
IDTipodato = C.IDTipodato,
ValidationEspecial = C.ValidationEspecial,
minimo = C.minimo,
maximo = C.minimo,
Requerido = C.Requerido,
Nombre = C.Campo.Nombre,
valores = C.Valores.Split(';')
}).ToList();
What am I doing wrong??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…