datamemberattribute

This commit is contained in:
2021-11-24 12:28:45 +01:00
parent 6a0424d9f1
commit 1bc9349f60
3 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using MySqlConnector;
using de.hottis.genericdatabaseapiservice.Models;
@ -27,7 +28,10 @@ namespace de.hottis.genericdatabaseapiservice.Services {
using (var reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) {
foreach (var propertyInfo in typeof(T).GetProperties()) {
Console.WriteLine(propertyInfo);
Console.WriteLine("Property name: {0}", propertyInfo);
var attributes = propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), true);
var dma = (DataMemberAttribute)attributes[0];
Console.WriteLine("DataMember name: {0} {1} ", dma.Name, dma.TypeId);
}
Console.WriteLine(reader.GetString("txt"));
}