I had some custom code in version 7.x that was using CommerceBuilder.Data; What is the reference in Gold. I am new to the Gold code but finding my way around for the most part. This has me a little stumped. If someone has a few minutes to help would be appreciated! Thanks in advance!
I had built a table to store customer notes and used "Database database = Token.Instance.Database;":
public string loadusernotes()
{
string Notes = string.Empty;
Database database = Token.Instance.Database;
DbCommand selectcommand = database.GetSqlStringCommand("select Notes from ac_UserNotes where UserId='"+ _UserId +"'");
database.AddInParameter(selectcommand, "@userId", System.Data.DbType.Int32, _UserId);
using (IDataReader reader = database.ExecuteReader(selectcommand))
{
while (reader.Read())
{
Notes = reader[0].ToString();
}
}
return Notes;
}
Database call from 7 using CommerceBuilder.Data?
Re: Database call from 7 using CommerceBuilder.Data?
Gold makes use of Nhibernate for data access so you have to adjust your queries accordingly.
Please have a look at this thread viewtopic.php?f=47&t=17108 I have posted some details about porting AC7 codes to Gold standards.
Code: Select all
public string loadusernotes()
{
string Notes = string.Empty;
var selectcommand = CommerceBuilder.DomainModel.NHibernateHelper.CreateSQLQuery("select Notes from ac_UserNotes where UserId='" + _UserId + "'");
selectcommand.SetParameter("userId", _UserId);
Notes = selectcommand.UniqueResult<string>();
return Notes;
}