I am using Ms Sql Server and I know that when using the keyword file I should put square braces around it within my query so it will be [file].
So how do I get around this when using nhibernate? Or do I even need to worry about it?
What Im trying to achieve is I want to get back a file based on the following query ie:
string query = "from File as f where f.CharacterID.CharacterID = :charID" +" AND f.FileExtension = :fileEx";
file = (File) session.CreateQuery(query).SetInt32("charID", 5).SetString("fileEx", ".txt")
mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="LicenseManagerDB.BusinessObjects.File, LicenseManagerDB" table="file">
<id name="FileID" column="fileid">
<generator class="identity" />
</id>
<property name="FileName" column="fileName" />
<many-to-one name="CharacterID" class="LicenseManagerDB.BusinessObjects.Character, LicenseManagerDB" column="characterid" not-null="true" />
<property name="FileSize" column="fileSize" />
<property name="ForPublic" column="forPublic" />
<property name="FileLocation" column="fileLocation" />
<property name="FileExtension" column="fileExtension" />
</class>
</hibernate-mapping>
The error message is: Specified cast is not valid.
|