schotime / NPoco

Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco
Apache License 2.0
848 stars 302 forks source link

How to get table name from exists POCO? #631

Closed xw2019 closed 3 years ago

xw2019 commented 3 years ago

i have set a table to save the seq for POCO key,that i can set the key before update the POCO. but how to get the tablename from POCO type?

[TableName("dbo.SeqNums")] [PrimaryKey("TableName", AutoIncrement=false)] [ExplicitColumns] public partial class SeqNum { [Column] public string TableName { get; set; } [Column] public string Prefix { get; set; } [Column] public int? Seq { get; set; } }

i found some way is issues but PocoDataFactory.ForType no longer support.

public static string GetTableName(Type type) { // Get the corresponding table information var tableInfo = PocoDataFactory .ForType(type) .TableInfo; return tableInfo.TableName; }

schotime commented 3 years ago

Database.PocoDataFactory.ForType(type).TableInfo still exists but you need a reference to the Database