Hi,
I don´t know the solution for this. I will try to explain..
I have a product class and a user class and a price class.
The price class is mapped many-to-one for both user and product class.
The price class, holds the ProductId the UserId and the price(varchar)
the problem is when i click on a product to show information, i want to bind this price to a textbox, (because the user can tell the price that they gave for the same product)
So when they click the "show product" button a textbox with the users price should appear and it most match the productid and the userid.
can anyone tell me the code for this? I can send the code that i have tried todo..
Code:
private Price GetPrice(int productId, int userId)
{
try
{
string hql = "SELECT count(price.Id) from Price price WHERE price.Product.Id = :productId AND price.User.Id = :userId";
IList<Query> queries = new List<Query>();
Query q = new Query();
q.ParamInt = productId;
q.ParamName = "productId";
queries.Add(q);
Query q2 = new Query();
q2.ParamInt = userId;
q2.ParamName = "userId";
queries.Add(q2);
int count = DataManagement.CoreRepository.RunCountStatement(hql, queries);
if (count > 0)
{
IList<Query> fetchQueries = new List<Query>();
Query fetchQ = new Query();
fetchQ.ParamName = "Product.Id";
fetchQ.ParamInt = productId;
fetchQ.ParamEvaluationType = EvaluationType.Equals;
fetchQueries.Add(fetchQ);
Query fetchQ2 = new Query();
fetchQ2.ParamName = "User.Id";
fetchQ2.ParamInt = userId;
fetchQ2.ParamEvaluationType = EvaluationType.Equals;
fetchQueries.Add(fetchQ2);
Price p = DataManagement.CoreRepository.RunQuery<Price>(fetchQueries);
return p.BuyPrice;
}
}
}
can someone edit the code to get it to work?
i get the product as querId and the user from the session
GetPrice(_productId,_userId);