Firstly - is the property mapped as an EnumStringType in the class
mapping?
Secondly - looking at the function, I'd personally be very tempted to
consider a wholesale redesign to use either the LINQ or QueryOver API
for improved maintainability/readability, e.g.
public IList<IEstimate> GetEstimates(List<EstimateType> estimateTypes,
string projectName, string estimateNumber, string jobNumber) {
return
SessionManager.GetSession().QueryOver<IEstimate>()
.Where(x => x.ProjectName ==
projectName)
.And(x => x.EstimateNumber ==
estimateNumber)
.And(x => x.JobNumber == jobNumber)
.And(x =>
x.EstimateType.IsIn(estimateTypes)
.List();
}
Thirdly - I didn't see anything related to transactions - is your
SessionManager / something else handling this? If not, I'd _strongly_
advise you to consider this.
/Pete
From: [email protected] [mailto:[email protected]] On
Behalf Of [email protected]
Sent: 28 June 2013 22:04
To: [email protected]
Subject: [nhusers] about convert enum to string nhibernate 3.3.3
i am upgrading nhibernate 2.1.2.GA to 3.3.3.GA version
but i found exception is for the enum will be convert to int where i
execute the iquery
here is my code,
public enum EstimateType {
FullyItemized,
UnitPriceJob
}
public IList<IEstimate> GetEstimates(List<EstimateType>
argEstimateTypeList, StringCriteria argProjectName, StringCriteria
argEstimateNumber, StringCriteria argJobNumber) {
StringBuilder aQuery = new StringBuilder();
aQuery.Append("select est from Estimate est ");
WhereBuilder aWhereBuilder = new
WhereBuilder(WhereBuilderType.Where, WhereBuilderJoin.And);
aWhereBuilder.AddCondition(" est.plEstimateType in
(:argEstimateTypeList) ");
aWhereBuilder.AddCondition(GetStringCriteriaQuery(argProjectName,
"est.plProjectName"));
aWhereBuilder.AddCondition(GetStringCriteriaQuery(argEstimateNumber,
"est.plEstimateNumber"));
aWhereBuilder.AddCondition(GetStringCriteriaQuery(argJobNumber,
"est.plJobNumber"));
aQuery.Append(aWhereBuilder.ToString());
IQuery anNhibernateQuery =
SessionManager.GetSession().CreateQuery(aQuery.ToString())
.SetParameterList("argEstimateTypeList",
argEstimateTypeList);
return anNhibernateQuery.List<IEstimate>();
}
I got an exception on return anNhibernateQuery.List<IEstimate>();
if I change the code and specify the EnumStringType, it wokrs
.SetParameterList("argEstimateTypeList", argEstimateTypeList, new
NHibernate.Type.EnumStringType<EstimateType>());
Unfortunately, I have too many Enum type and classes if i need to modify
the codes like that....
So is it possible to configure to set Convert Enum type to
EnumStringType as default? from the app.config or somewhere I can inject
the convert codes ?
Thank you very much
Arthur
--
You received this message because you are subscribed to the Google
Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.