I am creating a mini ORM to learn more about reflection in C #.
I also want to use Native and Pure C # and not use Entity Framework or SQL Server Management Objects .
public static void CreateTable(Type tableType, string connectionString)
{
}
The problem is the method CreateTable, it has a lot of problems, for example:
I could not find a standard way to create a table from a custom class.
How to create database tables from C # classes? : This solution is good, but not perfect. It may fail in some situations.
Datatypes!
There is no integration between C # and SQL Server data types. For example, varchar, nvarcharand textare all (or matched) string!
So, when the user creates this class:
public class Person
{
public int ID { get; set; }
public string Name { get; set; }
}
What type of SQL Server data should I use for Name?
Finally, if you generate an SQL query and execute it, this is the best way for this question, what is your suggestion?
source
share