Sqlite模型没有实例化?

时间:2018-03-11 18:04:03

标签: c# sqlite uwp

我的问题是,我不确定在哪一刻,我的SQLite模型停止实例化。要在特定数据表中插入对象,我使用创建的服务。此解决方案之前没有任何问题。我正在研究一些完全不同的部分(创建其他数据库服务),在某些时候,这就是发生的事情。

SOP是Sqlite表模型。

问题涉及SOP类的实例化。我没有改变代码,我99%肯定。

SOP表存在。

  

System.NullReferenceException:'对象引用未设置为对象的实例。*

代码:

private void Button_Click_1(object sender, RoutedEventArgs e)
      {
         //what happens when click -> Add SOP

        var sopService = new SOPsDbService();

        sopService.Insert(new SOPs
        {
            Description = this.textBoxDescription.Text,
            Standard = this.comboBoxStandard.SelectedValue.ToString(),
            Goal = this.textBoxTime.Text,
            FreqTimes = this.comboboxFreqTimes.SelectedValue.ToString(),
            FreqPeriod = this.comboboxFreqPeriod.SelectedItem.ToString()
        });




        //Then update SOP list
        //UpdateSOPList();

    }

表格型号:

using SQLite.Net.Attributes;
using System;

namespace eCILT.Assets.Model.dbModels.SOPs
{
public class SOPs
{
    [AutoIncrement, PrimaryKey]
    public int Id { get; set; }

    public string Name { get; set; }
    public string ImageUrl { get; set; }
    public string Description { get; set; }
    public string Phase { get; set; }
    public string Standard { get; set; }
    public string CorrectiveActions { get; set; }
    public string Tools { get; set; }
    public string Control { get; set; }
    public string ResponsibleUnit { get; set; }
    public string Goal { get; set; }
    public TimeSpan Norm { get; set; }
    public string OplSop { get; set; }
    public string FreqTimes { get; set; }
    public string FreqPeriod { get; set; }
    public string SheNote { get; set; }
    public string Line { get; set; }
    public string DesignedBy { get; set; }
    public string ApprovedAM { get; set; }
    public string AprovedSHE { get; set; }
    public string AprovedBHP { get; set; }
    public DateTime ApprovedAmDate { get; set; }
    public DateTime ApprovedSheDate { get; set; }
    public DateTime ApprovedBhpDate { get; set; }

    //Foreign keys
    public int GroupId { get; set; }
    public int CategoryId { get; set; }
    public int MachineId { get; set; }

    public SOPs()
    {
        //empty
    }

    public SOPs(string name, string imageUrl, string desc, string goal, TimeSpan norm, string oplSop, string freqTimes, string freqPeriod, string sheNote, int machineId, string line, string designedBy, string approvedAm, DateTime approvedShe, DateTime approvedAmDate, DateTime approvedSheDate)
    {
        this.Name = name;
        this.ImageUrl = imageUrl;
        this.Description = desc;
        this.Goal = goal;
        this.Norm = norm;
        this.OplSop = oplSop;
        this.FreqTimes = freqTimes;
        this.SheNote = sheNote;
        this.MachineId = machineId;
        this.Line = line;
        this.DesignedBy = designedBy;
        this.ApprovedAM = approvedAm;
        this.ApprovedSheDate = approvedShe;
        this.ApprovedAmDate = approvedAmDate;
        this.ApprovedSheDate = approvedSheDate;
    }

}
}

0 个答案:

没有答案