/// <summary> /// Add properties defined in the template. /// </summary> private void AddProperties() { foreach (var propInfo in TemplateType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { var typeArguments = new[] { TemplateType, propInfo.PropertyType }; if (TypeHelper.GetAttribute <DbRecordsetAttribute>(propInfo, out var rsAttr)) { Mode = DbExecutionMode.Query; AssertRecordsetIndex(rsAttr.Index); TypeHelper.AddBinding(ref recordsets, typeof(DbRecordsetBinding <,>), typeArguments, Setup, propInfo, rsAttr); } else if (TypeHelper.GetAttribute <DbRecordAttribute>(propInfo, out var rAttr)) { Mode = DbExecutionMode.Query; AssertRecordsetIndex(rsAttr.Index); TypeHelper.AddBinding(ref records, typeof(DbRecordBinding <,>), typeArguments, Setup, propInfo, rAttr); } else if (TypeHelper.GetAttribute <DbFieldAttribute>(propInfo, out var fAttr) || TypeHelper.GetAttribute <DbColumnAttribute>(propInfo, out var cAttr) && (fAttr = new DbFieldAttribute(cAttr)) != null) { Mode = DbExecutionMode.Query; TypeHelper.AddBinding(ref fields, typeof(DbFieldBinding <,>), typeArguments, Setup, propInfo, fAttr); } else if (TypeHelper.GetAttribute <DbParameterAttribute>(propInfo, out var pAttr)) { TypeHelper.AddBinding(ref parameters, typeof(DbParameterBinding <,>), typeArguments, Setup, propInfo, pAttr); } } }