Example #1
0
 public static void SetInstance(string ConnectionString)
 {
     if (Instance == null)
     {
         Instance = new TagAssocRepo(ConnectionString);
     }
 }
Example #2
0
        private IEnumerable <ItemModel> ItemCondition(string condition)

        {
            if (!String.IsNullOrEmpty(condition) && !condition.Equals("*"))
            {
                condition = " where " + condition;
            }
            else
            {
                condition = "";
            }
            Console.WriteLine("Select * from dbo.Items" + condition);
            List <ItemModel> MyList = new List <ItemModel>();
            ItemModel        curr;

            sqlConnection.Open();
            var arg = "Select * from dbo.Items" + condition;

            using (var command = new SqlCommand(arg, sqlConnection))
            {
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        curr             = new ItemModel();
                        curr.ID          = reader["ID"] as string;
                        curr.Name        = reader["Name"] as string;
                        curr.Description = reader["Description"] as string;
                        string owner = reader["OwnerId"] as string;
                        curr.OwnerId = TraderRepo.GetInstance().GetById(owner);
                        string price = reader["Price"] + "";
                        curr.Price = Int32.Parse(price);
                        curr.Photo = reader["Photo"] as byte[];
                        curr.Tags  = TagAssocRepo.GetInstance().ItemTags(curr.ID);
                        MyList.Add(curr);
                    }
                }
            }
            sqlConnection.Close();
            return(MyList);
        }