我在SimpleRepository中使用亚音速:
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的问题。有什么想法吗?
谢谢
发布于 2009-09-24 20:01:09
尝试更改您的类属性定义;
public int? CategoryID { get; set; }不能将int类型设置为null。
https://stackoverflow.com/questions/1472576
复制相似问题