Realizar una consulta sobre una fecha determinada con Hibernate

Esto simplemente es un apunte:
Si se quiere obtener una colección de registros dada una fecha en concreto utilizando la API de búsqueda de Hibernate se puede hacer de la siguiente manera:

.cf { font-family: Courier New; font-size: 10pt; color: black; background: white; }.cl { margin: 0px; }.cln { color: #2b91af; }.cb1 { color: teal; }.cb2 { color: blue; }.cb3 { color: maroon; } .cf { font-family: Courier New; font-size: 10pt; color: black; background: white; }.cl { margin: 0px; }.cb1 { color: teal; }.cb2 { color: blue; }.cb3 { color: maroon; } .cf { font-family: Courier New; font-size: 10pt; color: black; background: white; }.cl { margin: 0px; }.cln { color: #2b91af; }.cb1 { color: teal; }.cb2 { color: blue; }.cb3 { color: maroon; }

1 DateTime fecha = _dFecha.SelectedDate;

2 DateTime dFirst = new DateTime(fecha.Year, fecha.Month, fecha.Day);

3 DateTime dLast = new DateTime(fecha.AddDays(1).Year, fecha.AddDays(1).Month, fecha.AddDays(1).Day);

4

5 ICriterion objGE = new GeExpression(“Fecha”, dFirst);

6 ICriterion objLE = new LtExpression(“Fecha”, dLast);

7 ICriterion objAnd = new AndExpression(objGE, objLE);

8

9 return ActiveRecordMediator.FindAll(typeof (CIncidenciaAusenciaMateria), objAnd);

Esta funcion devuelve un array de objetos CTabla (que previamente hemos definido con ActiveRecord) cuya fecha coincida, aunque la hora sea distinta para cada registro.

Todavía no hay comentarios

Enviar un comentario nuevo

El contenido de este campo se mantiene privado y no se mostrará públicamente.
  • Etiquetas HTML permitidas: <a> <blockquote> <br> <cite> <code> <dd> <div> <dl> <dt> <em> <h1> <h2> <h3> <h4> <h5> <h6> <hr> <img> <li> <ol> <p> <pre> <span> <strong> <swf> <table> <tbody> <td> <th> <tr> <ul>
    Allowed Style properties: background-color, background-image, border, border-bottom, border-bottom-color, border-bottom-style, border-bottom-width, border-color, border-left, border-left-color, border-left-style, border-left-width, border-right, border-right-color, border-right-style, border-right-width, border-spacing, border-style, border-top, border-top-color, border-top-style, border-top-width, border-width, color, direction, font, font-family, font-size, font-style, font-variant, font-weight, height, left, line-height, list-style-type, margin, margin-bottom, margin-left, margin-right, margin-top, padding, padding-bottom, padding-left, padding-right, padding-top, right, text-align, text-decoration, top, width
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.

Más información sobre opciones de formato

CAPTCHA
Esta pregunta es para comprobar si eres un ser humano y evitar el envío automático desde sistemas de spam