IList <int>的流畅NHibernate映射?

时间:2016-05-11 19:24:08

标签: c# nhibernate fluent-nhibernate

我在NHibernate 4.0.0.4000中使用Fluent NHibernate 2.0.3 后端DB是Sqlite。

我的实体和映射定义如下:

public class PriceHistory
{
    public virtual int ID { get; set; }
    public virtual IList<long> Date { get; set; }
    public virtual IList<float> Price { get; set; }
    public virtual IList<int> Volume { get; set; }
    public virtual float MinPrice { get; set; }
    public virtual float MaxPrice { get; set; }
}

class PriceHistoryMap : ClassMap<PriceHistory>
{
    public PriceHistoryMap()
    {
        Table("PriceHistories");
        Id(x => x.ID);
        HasMany<long>(x => x.Date);
        HasMany<float>(x => x.Price);
        HasMany<int>(x => x.Volume);
        Map(x => x.MinPrice);
        Map(x => x.MaxPrice);
    }   
}

当我尝试启动应用程序时,我得到了这个例外:

Association references unmapped class: System.Int64

如果我有int,long或float,那没关系。我总是得到一个例外,好像我必须为每个基本值类型定义映射。

这里有什么不对?什么是值类型列表的正确映射?

2 个答案:

答案 0 :(得分:1)

我相信您可能必须将其作为import React, { Animated, Component, View } from 'react-native'; export default class EasingTest extends Component { state = { input: new Animated.Value(0) }; componentDidMount() { const max = 937; const output = this.state.input.interpolate({ inputRange: [0,max], outputRange: [0,1/max], easing: t => 1 / t }); setInterval(() => { const input = this.state.input.__getValue(); const expected = 1 / input; const actual = output.__getValue(); const error = Math.abs(expected - actual) / max; console.info(`f(${input}) = ${actual} (expected ${expected}, error ${Math.round(error * 100)}%`); }, 200); Animated.timing(this.state.input, { toValue: max, duration: 1000 }).start(); } render() { return <View /> } }

post也可能对您的问题有所帮助

答案 1 :(得分:0)

我不确定,但听起来你的漂浮物,彗星和长片住在不同的桌子上?

如果是这种情况,您可能需要为每个设置HasMany关系,如下所示:

HasMany<int>(x => x.Volume)
    .Table("PriceHistoryVolumes")
    .KeyColumn("PriceHistoryID")
    .Element("Volume");
相关问题