コード例 #1
0
        public string GetCatNameById(int id)
        {
            var q = (from r in edm.Categories where r.CategoryID == id select r);
            Category c = new Category();
            c = q.First<Category>();

            string name = c.Category_Name;
            return name;
        }
コード例 #2
0
        public int GetCatIdByName(string name)
        {
            var q = (from r in edm.Categories where r.Category_Name == name select r);
            Category c = new Category();
            c = q.First<Category>();

            int cid = c.CategoryID;
            return cid;
        }
コード例 #3
0
        public int AddNewCategory(string cat_name)
        {
            Category category_info = edm.Categories.FirstOrDefault(m => m.Category_Name == cat_name);
            Category category = new Category();
            //int cat_ID;
            if (category_info != null)
            {
                category.CategoryID = category_info.CategoryID;

            }
            else if (category_info == null)
            {
                //Category category = new Category();
                category.Category_Name = cat_name;
                edm.AddToCategories(category);
                edm.SaveChanges();
                //cat_ID = category.CategoryID;
            }

            //cat_ID = category_info.CategoryID;
            return category.CategoryID;
        }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Categories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCategories(Category category)
 {
     base.AddObject("Categories", category);
 }
コード例 #5
0
 /// <summary>
 /// Create a new Category object.
 /// </summary>
 /// <param name="categoryID">Initial value of the CategoryID property.</param>
 /// <param name="category_Name">Initial value of the Category_Name property.</param>
 public static Category CreateCategory(global::System.Int32 categoryID, global::System.String category_Name)
 {
     Category category = new Category();
     category.CategoryID = categoryID;
     category.Category_Name = category_Name;
     return category;
 }