4
How do I take the BD(Oracle) entity and generate in my system a class that represents that entity?
Ex: I have this entity
Client
ID int Primary key
Name varchar(100)
And now with the tool it already generates it:
using System;
using System.Data;
namespace meu_projeto.meu_folder.classes
{
public class Cliente{
public int ID { get; set; }
public string name { get; set; }
}
}
That is, generate a POCO class based on a BD(Oracle) entity, as I do?
I’m using WPF for this.
What have you tried? I mean, just the idea? You don’t even know where to start?
– Jéf Bueno
I haven’t done anything yet. I’m in the web search phase, among them Sopt, which for me, is the first research I do. But I am at the moment, researching also in other sources, but I believe a lot in Sopt. At the moment, I only have the idea and the request of the manager.
– pnet
My 20 cents: search about Reflection
– Jéf Bueno
Okay, I’ll start searching from now on. I’ll give you a vote on the comment, worth 20 cents, Hehehe.
– pnet
What I need at the moment is to read the database and bring the fields from a table. The whole question is how to identify a collection
(FK N => 1 ou 1 => N ou N => N, aí uma associação no meio)
.– pnet
If you are going to use a ORM, it usually already has a function to generate entities from the database structure. For example, to generate entities using Entity Framework: http://www.asp.net/mvc/overview/older-versions-1/models-data/creating-model-classes-with-the-entity-framework-cs
– Caffé
It’s fine to make a generator. I still can’t find a way to take Fields and types from a table and generate the poco.
– pnet
Use the Entity framework with the database first approach. Here’s a link explaining how it does: https://csharp.today/entity-framework-6-database-first-with-oracle/
– Tane
To get names and column types from an Oracle table:
select COLUMN_NAME, DATA_TYPE from ALL_TAB_COLUMNS where TABLE_NAME = 'NOME_TABELA'
. What is the specific difficulty to generate POCO?– Caffé
Dude, a while ago I made a query sql to mount the class, only it only works for SQL Server.
– Pablo Tondolo de Vargas
You can use the Entity Framework Code First from Database for this, it will generate all POCO Classes from your DB. https://msdn.microsoft.com/en-us/library/jj200620.aspx
– Renan Oliveira