Petapoco无法找到分割点

时间:2018-09-10 00:23:23

标签: .net petapoco

我遇到了我无法理解的错误。我检查了模型是否与数据库表相对应,但仍然出现一个使我觉得

的错误
  

System.InvalidOperationException:找不到之间的分割点   App.Model.SimCarBox和App.Model.MonoSimCar

这是引发错误的PetaPoco方法:

// Find the split point in a result set for two different pocos and return the poco factory for the first
        Delegate FindSplitPoint(Type typeThis, Type typeNext, string sql, IDataReader r, ref int pos)
        {

            // Last?
            if (typeNext == null)
                return PocoData.ForType(typeThis).GetFactory(sql, _sharedConnection.ConnectionString, ForceDateTimesToUtc, pos, r.FieldCount - pos, r);

            // Get PocoData for the two types
            PocoData pdThis = PocoData.ForType(typeThis);
            PocoData pdNext = PocoData.ForType(typeNext);

            // Find split point
            int firstColumn = pos;

            //var usedColumns = new Dictionary<string, bool>();  // <--- original (nuget.org Petapoco 5.1.140)
            var usedColumns = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);  // <--- my fix

            for (; pos < r.FieldCount; pos++)
            {
                // Split if field name has already been used, or if the field doesn't exist in current poco but does in the next
                string fieldName = r.GetName(pos);
                if (usedColumns.ContainsKey(fieldName) || (!pdThis.Columns.ContainsKey(fieldName) && pdNext.Columns.ContainsKey(fieldName)))
                {
                    return pdThis.GetFactory(sql, _sharedConnection.ConnectionString, ForceDateTimesToUtc, firstColumn, pos - firstColumn, r);
                }
                usedColumns.Add(fieldName, true);
            }

            throw new InvalidOperationException(string.Format("Couldn't find split point between {0} and {1}", typeThis, typeNext));
        }

数据模型

SIMCARBOX

[DataContract]
public class SimCarBox
{
    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string BachTimber { get; set; }

    [DataMember]
    public int BoxTimber { get; set; }

    [DataMember]
    public SimCarClassification Classification { get; set; }

    [DataMember]
    public NetType? NetType { get; set; }

    [DataMember]
    public NewarkProvider NewarkProvider { get; set; }

    [DataMember]
    public SimCarFormFactor FormFactor { get; set; }
}

MONOSIMCAR

[DataContract]
public class MonoSimCar : ICopyable<MonoSimCar>
{

    [DataMember]
    public long Id { get; set; }

    [DataMember]
    public string IccId { get; set; }

    [DataMember]
    public string Imsi { get; set; }

    [DataMember]
    public string Pun1 { get; set; }

    [DataMember]
    public string Pun2 { get; set; }

    [DataMember]
    public string Puc1 { get; set; }

    [DataMember]
    public string Puc2 { get; set; }

    [DataMember]
    public MonoSimCarBox Box { get; set; }

    [DataMember]
    public SimCarStatus Status { get; set; }

    [DataMember]
    public string Number { get; set; }

    public MonoSimCar Copy(bool clearIdentifier = true)
    {
        var instance = (MonoSimCar)MemberwiseClone();
        if (clearIdentifier) instance.Id = default(int);
        return instance;
        }
    }

在这里使用SQL

select   Activation.*,   SimCar.*,    SimCarNumber.Number,    
SimCarBox.* from [Activation] left join [SimCar] on SimCar.Id = 
Activation.SimCarId left join [SimCarBox] on SimCarBox.Id = SimCar.BoxId left 
join [SimCarNumber] on [SimCarNumber].IccId = [SimCar].IccId where 
SubscriptionId in (@0) and Activation.ProvisioningStatus <> @1.

正如我所说,它给出了此错误消息,这对我来说毫无意义。

找不到App.Model.SimCarBox和App.Model.MonoSimCar之间的分割点

0 个答案:

没有答案