Ejemplo n.º 1
0
 private IEnumerable <object> ReadRow(RowData row)
 {
     foreach (var column in row.Table.PrimaryKeyColumns)
     {
         yield return(row.GetValue(column.DbName));
     }
 }
Ejemplo n.º 2
0
        public override void Intercept(IInvocation invocation)
        {
            var info = new InvocationInfo(invocation);

            if (info.CallType == CallType.Set)
            {
                throw new Exception("Call to setter not allowed on an immutable type. Call Mutate() to get mutable object.");
            }

            if (info.Name == "IsNewModel")
            {
                invocation.ReturnValue = false;
                return;
            }

            if (info.Name == "Mutate")
            {
                invocation.ReturnValue = InstanceFactory.NewMutableRow(this.RowData, Transaction);
                return;
            }

            if (info.MethodType == MethodType.Property)
            {
                var name     = info.Name;
                var property = Properties.Single(x => x.CsName == name);

                if (property.Type == PropertyType.Value)
                {
                    invocation.ReturnValue = RowData.GetValue(property.Column.DbName);
                }
                else
                {
                    invocation.ReturnValue = GetRelation(info);
                }

                return;
            }

            throw new NotImplementedException($"No handler for '{info.Name}' implemented");
        }