none
Conversão RRS feed

  • Pergunta

  •  

    select

    mnts.NumSeq,

    usr.NomEmpUsr,

    minEsp.DscEsp,

    mnts.AssMnt,

    minTra.DatRecTrmMnt

     

    from dbo.SIC_Minuta mnts

    inner join dbo.SIC_MinutaEspecie minEsp on mnts.IdeEspMnt = minEsp.IdeEspMnt

    inner join dbo.SIC_Usuario usr on mnts.IdeEmpUsr = usr.IdeEmpUsr

    inner join dbo.SIC_MinutaTramite minTra on mnts.IdeMnt = minTra.IdeMnt

     

    where convert(varchar(10),minTra.DatRecTrmMnt,103) = '12/08/2008'

     

    Meus caros, como fazer esse tipo de conversão no LINQ?

    Menlhor dizendo, como ficaria essa query no LINQ utilizando o c# ?

     

    []'s

    terça-feira, 19 de agosto de 2008 17:18

Respostas

Todas as Respostas

  •  

    Error 1: The best overloaded method match for 'System.DateTime.Parse(string)' has some invalid arguments 

    Error 2: Argument '1': cannot convert from 'System.DateTime?' to 'string' 

     

    * minTra.DatRecTrmMnt is a datetime data type

     

    public DataTable CarregaMinutasPorData(string tableName, DateTime data)

    {

    try

    {

    Models.SicNetDataContext db = new Models.SicNetDataContext();

     

    var qry  =  from min in db.SIC_Minutas

    join minEsp in db.SIC_MinutaEspecies on min.IdeEspMnt equals minEsp.IdeEspMnt

    join usr in db.SIC_Usuarios on min.IdeEmpUsr equals usr.IdeEmpUsr

    join minTra in db.SIC_MinutaTramites on min.IdeMnt equals minTra.IdeMnt

    where

    DateTime.Parse(minTra.DatRecTrmMnt).ToString("dd/MM/yy")

    == data.ToString("dd/MM/yy")

    select new

    {

    min.NumSeq,

    usr.NomEmpUsr,

    minEsp.DscEsp,

    min.AssMnt,

    minTra.DatRecTrmMnt

    };

     

    DbCommand dbc = db.GetCommand(qry);

    return LinqDataExtensions.ToDataTable(qry, dbc, tableName);

    }

    catch (Exception ex)

    {

    throw ex;

    }

    }

    quarta-feira, 20 de agosto de 2008 14:02
  • Ola,

    Provavelmente o campo da sua DB é nullable e, sendo assim, precisa algo como:

    DateTime.Parse(minTra.Value.DatRecTrmMnt).ToString("dd/MM/yy") == data.ToString("dd/MM/yy")

    sábado, 23 de agosto de 2008 12:03