Hi, I'm pretty new to the NHibernate framework and am trying to use it to query my database. I have a lookup table set up (image.hbm.xml) with the properties set out as follows:
I then also have a class set up representing the lookup table (image.cs), and the name of the table in the database is IMAGE.
OK, now what I am doing is passing a string into a web service for example "2523-ATTACHMENT-57925", and the web service parses the number at the end of this string as an Integer which represents the primary key of the IMAGE table (field name LINK). I need to use this primary key as my search criteria and return the value from the field NOTES and return it as a string.
I have the following code set up and am not too sure how to continue with it to return the string..
Code:
<property name="ForeignLink" column="FORNBLG" />
<property name="IncludeInMerge" column="INCLUDE_IN_MERGE" />
<property name="ReferenceNumber" column="REF_NO" type="AnsiString"/>
<property name="FileName" column="FILENAME" type="AnsiString"/>
<property name="Notes" column="NOTES" type="AnsiString"/>
OK, now what I am doing is passing a string into a web service for example "2523-ATTACHMENT-57925", and the web service parses the number at the end of this string as an Integer which represents the primary key of the IMAGE table (field name LINK). I need to use this primary key as my search criteria and return the value from the field NOTES and return it as a string.
I have the following code set up and am not too sure how to continue with it to return the string..
Code:
using (ISession session = mSessionFactory.OpenSession())
{
try
{
if (myString.IndexOf("-ATTACHMENT-") >= 0)
{
//get primary key from myString (number after -ATTACHMENT-)
int pk = int.Parse(myString.Substring((myString.IndexOf("-ATTACHMENT-") + 12)));
ICriteria criteria = session.CreateCriteria(typeof(Image));
criteria.Add(new EqExpression("Link", pk, true));
Image image = (Image)criteria.UniqueResult();
return ..............
etc...
}
Comment