亚音速-谁能提供使用亚音速SimpleRepository持久存储对象列表/数组的示例? [英] Subsonic - can anyone provide an example of using Subsonic SimpleRepository to persist a list/array of objects?

查看:98
本文介绍了亚音速-谁能提供使用亚音速SimpleRepository持久存储对象列表/数组的示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找保留以下课程的可能方法.当我询问

I'm looking for possible ways to persist the following classes. Subsonic SimpleRepository looks like it might work, and people have said it should, when I asked a more general question.

但是我一直找不到一个如何执行此操作的示例-至少我能理解一个.

But I've been unable to find a single example of how to do this - or at least one I could understand.

任何人都可以给我指出一个例子,或者告诉我如何使用Subsonic将以下类映射到数据库吗?

Can anyone point me to an example, or tell me how I could use Subsonic to map the following classes to a database?

请注意,我还没有设计数据库-我希望Subsonic可以为我做到这一点,懒洋洋地把我当成...

Note that I haven't designed the database - I'm hoping Subsonic will do that for me, lazy sod that I am...

为了进一步说明,我希望Subsonic将我的对象模型转换为关系数据库,以处理所有父子关系和一对多关系这是隐含的.目前,我认为Subsonic无法做到这一点.但是,即使在对象模型中显式管理外键等的有效示例(不是代码片段)也会很有用.

Just to expand on the previous point - I'm hoping to have Subsonic convert my object model to a relational DB, dealing with all the Parent-Child and One-To-Many relationships that are implied. Currently, I don't think Subsonic can do this. But even a working example (not a code fragment) that explicitly managed foreign keys, etc in the object model would be useful.

一些我想坚持的背景和注意事项:

Some background and notes on the classes I want to persist:

  • 它们由控制某些测量设备的软件使用
  • 数据类包含名为 RunData 的对象数组 RunFn ,最多可保存数据 10次​​独立测量
  • 请注意, RunData 也包含一个数组 浮点数- RawY
  • 如有必要,我们可以将数组更改为其他类型的集合(列表等)
  • 针对SQL Server Express在VS2008中用C#开发
  • they are used by the software that controls some measuring equipment
  • the Data class contains an array of RunData objects called RunFn, which holds the data for up to 10 individual measurement runs
  • note that RunData also contains an array of floats - RawY
  • if necessary, we can change the arrays to some other type of collection (List<>, etc)
  • developing in C#, VS2008, for SQL Server Express

编辑:我正在使用Subsonic 3.0.0.3.

I'm using Subsonic 3.0.0.3.

public class RunData

{
    public DateTime StartDateTime { get; set; }
    public TimeSpan ElapsedTime { get; set; }

    private float[] _rawY;
    public float[] RawY
    {
        get
        {
            return _rawY;
        }
        set
        {
            _rawY = value;
        }
     }
 }

public Data
{
    public string OperatorId { get; set; }
    public string SampleId { get; set; }

    // CAN SUBSONIC DEAL WITH THIS ARRAY OF OBJECTS???
    private RunData[] _runFn;
    public RunData[] RunFn
    {
        get
        {
            return _runFn;
        }
        set
        {
            _runFn = value;
        }
    }
}

推荐答案

要回答我自己的问题...

To answer my own question...

尽管我发现其他一些帖子暗示Subsonic SimpleRepository可以根据对象模型自动生成关系架构,但事实并非如此.参见Rob Conery对这个问题的回答:

Despite some other postings I found which imply that Subsonic SimpleRepository can automatically generate a relational schema from an object model, this turns out NOT to be the case. See Rob Conery's answer to this question:

relationships-and-lazy-loading-in-subsonic-3 -0

但是,他正在努力,也许值得等待.

He's working on it, however, and it will probably be well worth the wait.

在此期间,我查看了 Fluent NHibernate ,这确实满足了我的要求.他们的源代码下载有一个名为Examples.FirstProject的演示项目,该项目演示了我正在寻找的功能.他们的文档似乎也更加成熟.

In the meantime, I've looked at Fluent NHibernate, and this does what I want right out of the box. Their source code download has a demo project called Examples.FirstProject which demonstrates the functionality I'm looking for. Their documentation seems to be much more mature as well.

但是,NHibernate的整体外观也更加复杂,因此,看看Subsonic的发展将会很有趣.

However, NHibernate also appears more complex overall, so it will be interesting to see what develops with Subsonic.

这是一个有用的链接,该链接显示了如何在SimpleRepository中自己管理外键-

Heres a useful link that shows how to mangage foreign keys yourself in SimpleRepository -

subsonic-3-simplerepository

我自己还没有尝试过,但是看起来它确实可以工作.

Have not tried it myself, but looks like it would actually work.

这篇关于亚音速-谁能提供使用亚音速SimpleRepository持久存储对象列表/数组的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆