0
DataMore1 dm1 = null;
DataMore2 dm2 = null;    

var list = session.QueryOver<Data>()
    .JoinAlias(data => data.DataMore1, () => dm1, NHibernate.SqlCommand.JoinType.LeftOuterJoin, Expression.Eq("Segment", 0))
    .JoinAlias(data => data.DataMore2, () => dm2, NHibernate.SqlCommand.JoinType.LeftOuterJoin, Expression.Eq("Segment", 0))
    .Select(d => 
        new Data ()
        {
            PlantID = d.PlantID,
            AreaID = d.AreaID,
            CellID = d.CellID,
            DeviceID = d.DeviceID,
            StartDateTime = d.StartDateTime,
            DataPoint01 = d.DataPoint01,
            DataMore1 = new List<DataMore1>(new List<DataMore1>
            {
                new DataMore1 { Segment = dm1.Segment, DataPoint101 = dm1.DataPoint101 }
            }),
            DataMore2 = new List<DataMore2>(new List<DataMore2>
            {
                new DataMore2 { Segment = dm2.Segment, DataPoint201 = dm2.DataPoint201 }
            })
        })
    .List<Data>();

この例外を生成します。

variable 'd' of type 'FNHSamples.Data' referenced from scope '', but it is not defined
4

1 に答える 1

-2

dが定義された後に開き中括弧がありません。リターンも追加しました。

次のことを試してください。

DataMore1 dm1 = null;
DataMore2 dm2 = null;    

var list = session.QueryOver<Data>()
    .JoinAlias(data => data.DataMore1, () => dm1, NHibernate.SqlCommand.JoinType.LeftOuterJoin, Expression.Eq("Segment", 0))
    .JoinAlias(data => data.DataMore2, () => dm2, NHibernate.SqlCommand.JoinType.LeftOuterJoin, Expression.Eq("Segment", 0))
    .ToList()
    .Select(d => 
        {
            return new Data ()
            {
                PlantID = d.PlantID,
                AreaID = d.AreaID,
                CellID = d.CellID,
                DeviceID = d.DeviceID,
                StartDateTime = d.StartDateTime,
                DataPoint01 = d.DataPoint01,
                DataMore1 = new List<DataMore1>(new List<DataMore1>{new DataMore1 { Segment = dm1.Segment, DataPoint101 = dm1.DataPoint101 }}),
                DataMore2 = new List<DataMore2>(new List<DataMore2>{new DataMore2 { Segment = dm2.Segment, DataPoint201 = dm2.DataPoint201 }})
            };
        })
        .List<Data>();
于 2013-07-26T18:11:14.863 に答える