本文介绍了无法从autobuggi.models.carcategory转换为autobuggi.repository.autobuggi.carcategory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法从AutoBuggi.Models.CarCategory转换为AutoBuggi.Repository.AutoBuggi.CarCategory



我尝试过:



这是我的CategoryRepository类文件:

Cannot convert from AutoBuggi.Models.CarCategory to AutoBuggi.Repository.AutoBuggi.CarCategory

What I have tried:

This is my CategoryRepository Class file:

namespace AutoBuggi.Repository
{
    public class CategoryRepository
    {
        //private object dbCategory;
       
        public Guid SaveCategory(Models.CarCategory model)
        {
            try
            {
                using (var dbcontext = new AutoBuggiEntities())
                {
                    var dbCategory = new Models.CarCategory()
                    {
                        Id = Guid.NewGuid(),
                        CategoryId = model.CategoryId,
                        VariantName = model.VariantName
                    };
                    dbcontext.CarCategories.Add(dbCategory);
                    dbcontext.SaveChanges();
                }
            }
            catch(Exception)
            {
            }

            return Guid.Empty;
       }
    }
}







这是我的型号类文件:




This is my Model Class File:

namespace AutoBuggi.Models
{
    public class CarCategory
    {
        public Guid Id { get; set; }
        public int CategoryId { get; set; }

        [DisplayAttribute(Name = "Variant Name")]
        public string VariantName { get; set; }
    }
}

推荐答案

Repository.AutoBuggi.CarCategory

对象而不是

Models.CarCategory


这篇关于无法从autobuggi.models.carcategory转换为autobuggi.repository.autobuggi.carcategory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 14:22