Using SQL to pull Data
Hi all. I am fairly new at programming, and very new to fluent. I am trying to pull some data from my database using CreateSQLQuery(), and am not having much luck. If I want to pull all the data from my database that has unit field = Some value and a name field = "some value" what is the best way to accomplish that?
I was trying to use IQuery as so:
public static Pi_Tag GetTagByUnitAndName(int unit, string name)
{
using (ISession session = DataConnector.Instance.sessionFactory.OpenSession())
{
IQuery query = session.CreateSQLQuery("SELECT * FROM pi_tag WHERE unit = " + unit.ToString() + " AND tag_name = " + name);
Pi_Tag tag = (Pi_Tag)query.UniqueResult();
return tag;
}
}