首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SubSonic3 -列“CategoryID”不能为null

SubSonic3 -列“CategoryID”不能为null
EN

Stack Overflow用户
提问于 2009-09-24 15:51:45
回答 1查看 194关注 0票数 0

我在SimpleRepository中使用亚音速:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.DataProviders;
using SubSonic.Repository;

namespace SubSonicTest
{
    class Program
    {
        public class Product
        {
            public int ProductID { get; set; }
            public int CategoryID { get; set; }
            public string ProductName { get; set; }
            public decimal UnitPrice { get; set; }
            public bool Discontinued { get; set; }


        }
        static void Main(string[] args)
        {

            var repo = new SimpleRepository("SubSonic", SimpleRepositoryOptions.RunMigrations);
            var newProduct = new Product();
            newProduct.CategoryID = 5;
            newProduct.ProductName = "Pretzel";
            newProduct.UnitPrice = 100;
            newProduct.Discontinued = false;
            repo.Add<Product>(newProduct);
        }
    }
}

但是,当我运行此命令时,我得到:列'CategoryID‘不能为空这是MySQL、windows和VS2008的问题。有什么想法吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2009-09-24 20:01:09

尝试更改您的类属性定义;

代码语言:javascript
复制
public int? CategoryID { get; set; }

不能将int类型设置为null。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1472576

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档