내가 유창함 자 NHibernate와 함께 자동 매핑을 사용하고, 그리고 NHibernate에 밀리 초 벗겨하지 않도록하려면 다음 코드를 사용하고있는 타임 스탬프 열 비교와 쿼리 :이 아주 잘 작동LINQ의 NHibernate에
public class TimestampTypeConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => x.Type == typeof(DateTime) || x.Type == typeof(DateTimeOffset));
}
public void Apply(IPropertyInstance instance)
{
instance.CustomType<TimestampType>();
}
}
를, 그래서 데이터는 데이터베이스에 올바르게 저장됩니다. 나는 다음과 같은 LINQ 쿼리를 실행할 때
그러나, 나는 그것을 기대 일치하지 않습니다
bool isDuplicate = session.Query<TagData>()
.Any(x => x.TagName == message.EventTag.TagName
&& x.TimeStamp == message.EventTag.TimeStamp.UtcDateTime);
결과 SQL은 다음과 같습니다,이 작동하지 않는 이유를 설명 :
select tagdata0_."Id" as column1_0_, tagdata0_."TagName" as column2_0_,
tagdata0_."TimeStamp" as column3_0_, tagdata0_."Value" as column4_0_,
tagdata0_."QualityTimeStamp" as column5_0_, tagdata0_."QualitySubstatus" as column6_0_,
tagdata0_."QualityExtendedSubstatus" as column7_0_, tagdata0_."QualityLimit" as column8_0_,
tagdata0_."QualityDataSourceError" as column9_0_, tagdata0_."QualityTagStatus" as column10_0_,
tagdata0_."TagType" as column11_0_ from "TagData" tagdata0_
where tagdata0_."TagName"=:p0 and tagdata0_."TimeStamp"=:p1 limit 1;
:p0 = 'VALVE_HW_CMD' [Type: String (0)],
:p1 = 01.03.2013 16:51:30 [Type: DateTime (0)]
어떻게 전체 정밀도를 사용하도록 생성 된 쿼리를 강제 적용 할 수 있습니까?
BTW, message.EventTag.TimeStamp
이있는 DateTimeOffset