I added a new ADO.NET ORM object inside my project based on an already existing database. I was able to create a new object but I don't quite understand how to insert my new object in the database and get the ID generated from it.
From the example shown in the link, I just don't understand what is their TestDBEntities Class
I am also opened to any ORM suggestion based off experience! Thanks!
public static void Insert_Demande_Willy(string ModelPath)
{
using (TestDBEntities ctx = new TestDBEntities())
{
Model.CreateDessin newDemande = new CreateDessin()
{
DateProduite = DateTime.Now,
GenerateBom = Willy.Properties.Settings.Default.GenerateBom.ToString(),
MailAdress = Willy.Properties.Settings.Default.Email,
NotifyRBRE = Willy.Properties.Settings.Default.Wilma_RBRE.ToString(),
NotifyRBTK = Willy.Properties.Settings.Default.Wilma_RBTK.ToString(),
NotifyTLS = Willy.Properties.Settings.Default.Wilma_TLS.ToString(),
NotifyTQ = Willy.Properties.Settings.Default.Wilma_TQ.ToString(),
PathDessin = ModelPath,
SendingComputer = Environment.MachineName,
UserName = Environment.UserName
};
Insert_Demande_Willy_DTL(newDe)
}
}
/// <summary>
/// Importer Statuts enumeration
/// Setter priorité
/// NoECO juste quand check?
/// IF DEV TESTED BY
/// </summary>
/// <param name="ID"></param>
private static void Insert_Demande_Willy_DTL(int ID)
{
Model.CreateDessinDTL newDemandeDTL = new CreateDessinDTL()
{
ConfigName = "",
CreatePDF = Willy.Properties.Settings.Default.GeneratePDF.ToString(),
C_ID = ID,
NoECO = Willy.Properties.Settings.Default.EcoName,
Priority = 2,
Statut = "Willy2",
};
}
I somehow found a way to make this thing work. Unfortunately, some members of some objects won't show with Intellisence.
/// <summary>
/// Setter priorité
/// NoECO juste quand check?
/// </summary>
/// <param name="ID"></param>
private static void Insert_Demande_Willy_DTL(int ID)
{
{
DemoInfo_IndusEntities context = new DemoInfo_IndusEntities();
context.CreateDessinDTL.Add(new CreateDessinDTL_Demo()
{
ConfigName = "",
C_ID = ID,
NoECO = Willy.Properties.Settings.Default.EcoName,
Priority = 2,
Statut = AppConfig.Controller.Statuts.Willy.Willy2,
TestedBy = Environment.UserName
//CreatePDF = Willy.Properties.Settings.Default.GeneratePDF.ToString(),
});
context.SaveChanges();
}}