//Database Access Layer Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace DAL.LinqToSql
{
public static class CartLinqDB
{
private static string _connectionString;
private static string ConnectionString
{
get
{
return _connectionString;
}
set
{
if (string.IsNullOrEmpty(_connectionString) == false)
{
BindConnection();
}
_connectionString = value;
}
}
static CartLinqDB()
{
//Initializing connection string
BindConnection();
}
/// <summary>
/// Initializing connection string
/// </summary>
private static void BindConnection()
{
ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
/// <summary>
/// return the basketItem details
/// </summary>
/// <param name="BasketItemId"></param>
/// <returns></returns>
public static shoppingcart GetBasketItemdetails(string SessionID, string ProductID)
{
shoppingcart cart;
using (LinqToSqlDbDataContext db = new LinqToSqlDbDataContext(ConnectionString))
{
cart = db.shoppingcarts.Single(p => p.SessionID == SessionID && p.ProductCode==ProductID);
}
return cart;
}
}
}
|