diff --git a/SHERPA.BBM/DatabaseModels/FattModel.cs b/SHERPA.BBM/DatabaseModels/FattModel.cs new file mode 100644 index 0000000..67a1b76 --- /dev/null +++ b/SHERPA.BBM/DatabaseModels/FattModel.cs @@ -0,0 +1,61 @@ +using System; +using System.Data.Entity; +using System.Linq; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SHERPA.BBM.DatabaseModels +{ + /// + /// Tabella Fatture - Documenti + /// + [Table("Fatture")] + public class FattModel + { + #region Public Properties + + [Key, Column("IdxFatt", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxFatt { get; set; } + + [Column("anno", Order = 1)] + public int? anno { get; set; } = DateTime.Today.Year; + + [Column("num", Order = 2)] + public int? num { get; set; } = 0; + + [Column("idxCli", Order = 3)] + public int? idxCli { get; set; } + + [Column("tipo", Order = 4), MaxLength(50)] + public string tipo { get; set; } = ""; + + [Column("emesso", Order = 5)] + public DateTime emesso { get; set; } = DateTime.Now; + + [Column("ritenuta", Order = 6)] + public float ritenuta { get; set; } = 0; + + [Column("scelta", Order = 7)] + public bool scelta { get; set; } = false; + + [Column("dataPagam", Order = 8)] + public DateTime? dataPagam { get; set; } + + [Column("scadenza", Order = 9), DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime scadenza { get; set; } + + [Column("token", Order = 10), MaxLength(250)] + public string token { get; set; } = ""; + + [Column("new_id", Order = 11), MaxLength(50)] + public string new_id { get; set; } = ""; + + [Column("dtEvent", Order = 12)] + public DateTime dtEvent { get; set; } + + [Column("changed", Order = 13)] + public int changed { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/SHERPA.BBM/FattDbContext.Views.cs b/SHERPA.BBM/FattDbContext.Views.cs new file mode 100644 index 0000000..438c15b --- /dev/null +++ b/SHERPA.BBM/FattDbContext.Views.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System.Data.Entity.Infrastructure.MappingViews; + +[assembly: DbMappingViewCacheTypeAttribute( + typeof(SHERPA.BBM.FattDbContext), + typeof(Edm_EntityMappingGeneratedViews.ViewsForBaseEntitySetsa98ba0b8c09d09077376bac5ee6a1952d01e61f4c783e65d3c07347567873c36))] + +namespace Edm_EntityMappingGeneratedViews +{ + using System; + using System.CodeDom.Compiler; + using System.Data.Entity.Core.Metadata.Edm; + + /// + /// Implements a mapping view cache. + /// + [GeneratedCode("Entity Framework 6 Power Tools", "0.9.2.0")] + internal sealed class ViewsForBaseEntitySetsa98ba0b8c09d09077376bac5ee6a1952d01e61f4c783e65d3c07347567873c36 : DbMappingViewCache + { + /// + /// Gets a hash value computed over the mapping closure. + /// + public override string MappingHashValue + { + get { return "a98ba0b8c09d09077376bac5ee6a1952d01e61f4c783e65d3c07347567873c36"; } + } + + /// + /// Gets a view corresponding to the specified extent. + /// + /// The extent. + /// The mapping view, or null if the extent is not associated with a mapping view. + public override DbMappingView GetView(EntitySetBase extent) + { + if (extent == null) + { + throw new ArgumentNullException("extent"); + } + + var extentName = extent.EntityContainer.Name + "." + extent.Name; + + if (extentName == "CodeFirstDatabase.FattModel") + { + return GetView0(); + } + + if (extentName == "FattDbContext.DbSetFatture") + { + return GetView1(); + } + + return null; + } + + /// + /// Gets the view for CodeFirstDatabase.FattModel. + /// + /// The mapping view. + private static DbMappingView GetView0() + { + return new DbMappingView(@" + SELECT VALUE -- Constructing FattModel + [CodeFirstDatabaseSchema.FattModel](T1.FattModel_IdxFatt, T1.FattModel_anno, T1.FattModel_num, T1.FattModel_idxCli, T1.FattModel_tipo, T1.FattModel_emesso, T1.FattModel_ritenuta, T1.FattModel_scelta, T1.FattModel_dataPagam, T1.FattModel_scadenza, T1.FattModel_token, T1.[FattModel.new_id], T1.FattModel_dtEvent, T1.FattModel_changed) + FROM ( + SELECT + T.IdxFatt AS FattModel_IdxFatt, + T.anno AS FattModel_anno, + T.num AS FattModel_num, + T.idxCli AS FattModel_idxCli, + T.tipo AS FattModel_tipo, + T.emesso AS FattModel_emesso, + T.ritenuta AS FattModel_ritenuta, + T.scelta AS FattModel_scelta, + T.dataPagam AS FattModel_dataPagam, + T.scadenza AS FattModel_scadenza, + T.token AS FattModel_token, + T.new_id AS [FattModel.new_id], + T.dtEvent AS FattModel_dtEvent, + T.changed AS FattModel_changed, + True AS _from0 + FROM FattDbContext.DbSetFatture AS T + ) AS T1"); + } + + /// + /// Gets the view for FattDbContext.DbSetFatture. + /// + /// The mapping view. + private static DbMappingView GetView1() + { + return new DbMappingView(@" + SELECT VALUE -- Constructing DbSetFatture + [SHERPA.BBM.FattModel](T1.FattModel_IdxFatt, T1.FattModel_anno, T1.FattModel_num, T1.FattModel_idxCli, T1.FattModel_tipo, T1.FattModel_emesso, T1.FattModel_ritenuta, T1.FattModel_scelta, T1.FattModel_dataPagam, T1.FattModel_scadenza, T1.FattModel_token, T1.[FattModel.new_id], T1.FattModel_dtEvent, T1.FattModel_changed) + FROM ( + SELECT + T.IdxFatt AS FattModel_IdxFatt, + T.anno AS FattModel_anno, + T.num AS FattModel_num, + T.idxCli AS FattModel_idxCli, + T.tipo AS FattModel_tipo, + T.emesso AS FattModel_emesso, + T.ritenuta AS FattModel_ritenuta, + T.scelta AS FattModel_scelta, + T.dataPagam AS FattModel_dataPagam, + T.scadenza AS FattModel_scadenza, + T.token AS FattModel_token, + T.new_id AS [FattModel.new_id], + T.dtEvent AS FattModel_dtEvent, + T.changed AS FattModel_changed, + True AS _from0 + FROM CodeFirstDatabase.FattModel AS T + ) AS T1"); + } + } +} diff --git a/SHERPA.BBM/FattDbContext.cs b/SHERPA.BBM/FattDbContext.cs new file mode 100644 index 0000000..65c8a5e --- /dev/null +++ b/SHERPA.BBM/FattDbContext.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data.Entity; + +namespace SHERPA.BBM +{ + public class FattDbContext : DbContext + { + // Il contesto è stato configurato per utilizzare una stringa di connessione 'BBMModel' dal file di configurazione + // dell'applicazione (App.config o Web.config). Per impostazione predefinita, la stringa di connessione è destinata al + // database 'BBMModel' nell'istanza di LocalDb. + // + // Per destinarla a un database o un provider di database differente, modificare la stringa di connessione 'BBMModel' + // nel file di configurazione dell'applicazione. + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] + //public DatabaseContext() : base("BBMModel") + public FattDbContext() : base("Data Source=SQL2012DEV;Initial Catalog=SHERPA.Fatt;User ID=sa;Password=keyhammer16;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework") + { + } + + public FattDbContext(string connectionString) : base(connectionString) + { + //Database.CreateIfNotExists(); + ////Database.SetInitializer(new MigrateDatabaseToLatestVersion()); + //Database.Initialize(false); + } + + public virtual DbSet DbSetFatture { get; set; } + + } +} diff --git a/SHERPA.BBM/SHERPA.BBM.csproj b/SHERPA.BBM/SHERPA.BBM.csproj index 0323733..69cfd46 100644 --- a/SHERPA.BBM/SHERPA.BBM.csproj +++ b/SHERPA.BBM/SHERPA.BBM.csproj @@ -76,6 +76,9 @@ + + +