在亚音速部分类中添加新属性

发布于 2024-10-01 00:36:12 字数 447 浏览 6 评论 0原文

我在 sqlserver 的表(活动)中添加了一个新列(创建日期)。 我正在使用 subsonic 2.0,如何将此列添加为 subsonic 部分类中的属性,以便我可以插入和更新“DateCreated”列的值。 DateCreated 将由用户从 GUI 提供。

以下是我正在使用的代码,但它插入 NULL &从数据库中检索 NULL。

public partial class ActivityInscription 
{

   public struct Columns
   {
        public static string IsInMixedList = @"IsInMixedList";
   }
   public bool? IsInMixedList
   {
       get;
       set;
   }

}

请任何人帮我解决这个问题。

I added a new column(DateCreated) in a table(Activity) in sqlserver.
and I am using subsonic 2.0, how can I add this column as property in subsonic partial class, so that I can insert and update the value of "DateCreated" Column.
DateCreated will be provided by the user from the GUI.

following is the code I m using but it insert NULL & retrive NULL from the database.

public partial class ActivityInscription 
{

   public struct Columns
   {
        public static string IsInMixedList = @"IsInMixedList";
   }
   public bool? IsInMixedList
   {
       get;
       set;
   }

}

Please any one help me to resolve this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

池木 2024-10-08 00:36:12

如果您将该列添加到数据库中,则只需重建 DAL。它将拾取新列并将其添加到亚音速 DAL 中。在你的情况下没有理由进行部分类。如果表“Activity”是配置文件中表的亚音速列表(includeTableList)的一部分,则这将起作用。

If you added the column to the database then just rebuild the DAL. It will pick up the new column and add it to the subsonic DAL. There is no reason for a Partial class in your case. This will work providing that the table "Activity" is part of your subsonic list (includeTableList) of tables in the config file.

失与倦" 2024-10-08 00:36:12

以下是我使用的解决方案,它正在工作:

公共部分类活动
{

    public DateTime? DateCreated
    {
        get;
        set;
    }

    protected override void BeforeInsert()
    {
        TableSchema.Table tblSchema = Schema;

        TableSchema.TableColumn ccDateCreated = new TableSchema.TableColumn(tblSchema);

            ccrDateCreated.ColumnName = "DateCreated";
            ccDateCreated.DataType = DbType.DateTime;
            ccDateCreated.MaxLength = 0;
            ccDateCreated.AutoIncrement = false;
            ccDateCreated.IsNullable = false;
            ccDateCreated.IsPrimaryKey = false;
            ccDateCreated.IsForeignKey = false;
            ccDateCreated.IsReadOnly = false;
            ccDateCreated.DefaultSetting = @"";
            ccDateCreated.ForeignKeyTableName = "";

        if (!tblSchema.Columns.Contains("DateCreated"))
        {
            tblSchema.Columns.Add(ccDateCreated); 
        }

        if (this.GetSchema().Columns.Contains("DateCreated"))
            this.SetColumnValue(Columns.DateCreated, DateCreated);

        base.BeforeInsert();
    }

}

现在它工作正常 &插入我从 GUI 提供的值。

Following is the solution, I used and it is working:

public partial class Activity
{

    public DateTime? DateCreated
    {
        get;
        set;
    }

    protected override void BeforeInsert()
    {
        TableSchema.Table tblSchema = Schema;

        TableSchema.TableColumn ccDateCreated = new TableSchema.TableColumn(tblSchema);

            ccrDateCreated.ColumnName = "DateCreated";
            ccDateCreated.DataType = DbType.DateTime;
            ccDateCreated.MaxLength = 0;
            ccDateCreated.AutoIncrement = false;
            ccDateCreated.IsNullable = false;
            ccDateCreated.IsPrimaryKey = false;
            ccDateCreated.IsForeignKey = false;
            ccDateCreated.IsReadOnly = false;
            ccDateCreated.DefaultSetting = @"";
            ccDateCreated.ForeignKeyTableName = "";

        if (!tblSchema.Columns.Contains("DateCreated"))
        {
            tblSchema.Columns.Add(ccDateCreated); 
        }

        if (this.GetSchema().Columns.Contains("DateCreated"))
            this.SetColumnValue(Columns.DateCreated, DateCreated);

        base.BeforeInsert();
    }

}

Now it is working fine & inserting the values that I provide from the GUI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文