Dapper,多映射,oracle

时间:2015-12-11 14:56:09

标签: c# oracle dapper

有人可以建议,我做错了什么,拜托?

我有clases:

  Release
  {
    public string ReleaseId {get; set;}
    ..
    public IList<Script> Scripts {get; set; }  

  }

  Script
  {
    Guid ScriptId {get; set;}
    ..
    string ReleaseId {get; set;}
  }

比我有Oracle存储过程:

PROCEDURE get_releases(parameter_in IN VARCHAR2, parameter_out SYS_REFCURSOR) AS
  BEGIN
      cur := 'select  r.release_id,
                                ...
                                      h.script_id,
                                ...';

        OPEN OUT_CURSOR FOR 
      cur;
  END;

我试图获取版本列表:

var parameters = new OracleDynamicParameters();
  parameters.Add("parameter_out", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
  parameters.Add("parameter_in", value);

  var lookup = new Dictionary<string, Release>();
  var result = connection.Query<Release, Script, Release>(
                        "get_releases", 
                        (release, script) =>
                        {
                            if (!lookup.ContainsKey(release.ReleaseId))
                            {
                                lookup.Add(release.ReleaseId, release);
                            }
                            var cr = lookup[release.ReleaseId];
                            if (cr.Scripts == null)
                            {
                                cr.Scripts = new List<Script>();
                            }
                            cr.Scripts.Add(script);
                            return cr;
                        },
                        parameters,
                        commandType: CommandType.StoredProcedure,
                        splitOn: "ReleaseId"
  );

但它以异常崩溃:     &#34;当使用多映射API时,如果您有除Id \ r \ n \ nParameter name之外的其他键,请确保设置splitOn参数:splitOn&#34;   即使splitOn被明确设置。

堆栈跟踪:

    at Dapper.SqlMapper.GetNextSplit(Int32 startIdx, String splitOn, IDataReader reader) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 2111
   at Dapper.SqlMapper.GenerateDeserializers(Type[] types, String splitOn, IDataReader reader) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 2056
   at Dapper.SqlMapper.<MultiMapImpl>d__71`8.MoveNext() in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1857
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.MultiMap[TFirst,TSecond,TThird,TFourth,TFifth,TSixth,TSeventh,TReturn](IDbConnection cnn, String sql, Delegate map, Object param, IDbTransaction transaction, Boolean buffered, String splitOn, Nullable`1 commandTimeout, Nullable`1 commandType) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1829
   at Dapper.SqlMapper.Query[TFirst,TSecond,TReturn](IDbConnection cnn, String sql, Func`3 map, Object param, IDbTransaction transaction, Boolean buffered, String splitOn, Nullable`1 commandTimeout, Nullable`1 commandType) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1660

非常感谢,我已经非常绝望了。

兰格

0 个答案:

没有答案