ソースを参照

NEW Factories génériques générées automatiquement depuis un template t4

julien.legrand 8 年 前
コミット
23bb835497

+ 22 - 2
CD67.ModeleMVC.Factory/CD67.ModeleMVC.Factory.csproj

@@ -53,6 +53,7 @@
       <HintPath>..\packages\System.Linq.Dynamic.1.0.7\lib\net40\System.Linq.Dynamic.dll</HintPath>
       <Private>True</Private>
     </Reference>
+    <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
@@ -60,9 +61,19 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Internal\EXEMPLE_TYPE_VIKINGFactory.cs">
+      <DependentUpon>GenericFactories.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Internal\EXEMPLE_VIKINGSFactory.cs">
+      <DependentUpon>GenericFactories.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Internal\GenericFactories.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>GenericFactories.tt</DependentUpon>
+    </Compile>
     <Compile Include="SOUS_TYPE_VIKINGFactory.cs" />
-    <Compile Include="VIKINGSFactory.cs" />
-    <Compile Include="TYPE_VIKINGFactory.cs" />
+    <Compile Include="EXEMPLE_VIKINGSFactory.cs" />
     <Compile Include="Internal\BaseFactory.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
@@ -76,6 +87,15 @@
       <Name>CD67.ModeleMVC.Entity</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Internal\GenericFactories.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>GenericFactories.cs</LastGenOutput>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 1 - 7
CD67.ModeleMVC.Factory/VIKINGSFactory.cs → CD67.ModeleMVC.Factory/EXEMPLE_VIKINGSFactory.cs

@@ -8,14 +8,8 @@ using System.Threading.Tasks;
 
 namespace CD67.ModeleMVC.Factory
 {
-    public class VIKINGSFactory : Internal.BaseFactory<Entity.EXEMPLE_VIKINGS>
+    public partial class VIKINGSFactory : Internal.BaseFactory<Entity.EXEMPLE_VIKINGS>
     {
-        /// <summary>
-        /// Constructeur public lié au constructeur de base
-        /// </summary>
-        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
-        public VIKINGSFactory(Entities dbContext) : base(dbContext) { }
-
         /// <summary>
         /// Retourne tous les objets (en surchargeant la méthode standard)
         /// </summary>

+ 21 - 0
CD67.ModeleMVC.Factory/Internal/EXEMPLE_TYPE_VIKINGFactory.cs

@@ -0,0 +1,21 @@
+using CD67.ModeleMVC.Entity;
+using System.Linq;
+
+namespace CD67.ModeleMVC.Factory
+{
+	/// <summary>
+    /// NE PAS MODIFIER
+    /// C'est une classe partielle, elle peut être complétée avec une classe partielle du même nom
+    /// Factory générée automatiquement à l'aide du fichier GenericFactories.tt
+    /// pour toutes les entités du fichier entity : /CD67.ModeleMVC.Entity/EntityModel.edmx
+    /// </summary>
+	public partial class EXEMPLE_TYPE_VIKINGFactory : Internal.BaseFactory<EXEMPLE_TYPE_VIKING>
+	{
+		/// <summary>
+        /// Constructeur public lié au constructeur de base
+        /// </summary>
+        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
+		public EXEMPLE_TYPE_VIKINGFactory(Entities dbContext) : base(dbContext) { }
+	}
+}
+	

+ 21 - 0
CD67.ModeleMVC.Factory/Internal/EXEMPLE_VIKINGSFactory.cs

@@ -0,0 +1,21 @@
+using CD67.ModeleMVC.Entity;
+using System.Linq;
+
+namespace CD67.ModeleMVC.Factory
+{
+	/// <summary>
+    /// NE PAS MODIFIER
+    /// C'est une classe partielle, elle peut être complétée avec une classe partielle du même nom
+    /// Factory générée automatiquement à l'aide du fichier GenericFactories.tt
+    /// pour toutes les entités du fichier entity : /CD67.ModeleMVC.Entity/EntityModel.edmx
+    /// </summary>
+	public partial class EXEMPLE_VIKINGSFactory : Internal.BaseFactory<EXEMPLE_VIKINGS>
+	{
+		/// <summary>
+        /// Constructeur public lié au constructeur de base
+        /// </summary>
+        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
+		public EXEMPLE_VIKINGSFactory(Entities dbContext) : base(dbContext) { }
+	}
+}
+	

+ 2 - 0
CD67.ModeleMVC.Factory/Internal/GenericFactories.cs

@@ -0,0 +1,2 @@
+
+

+ 341 - 0
CD67.ModeleMVC.Factory/Internal/GenericFactories.tt

@@ -0,0 +1,341 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF6.Utility.CS.ttinclude"#>
+<#@ output extension=".cs"#>
+
+<#
+const string inputFile = @"../../CD67.ModeleMVC.Entity/EntityModel.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var	fileManager = EntityFrameworkTemplateFileManager.Create(this);
+var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
+
+foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
+{
+    fileManager.StartNewFile(entity.Name + "Factory.cs");
+	#>
+using CD67.ModeleMVC.Entity;
+using System.Linq;
+
+namespace CD67.ModeleMVC.Factory
+{
+	/// <summary>
+    /// NE PAS MODIFIER
+    /// C'est une classe partielle, elle peut être complétée avec une classe partielle du même nom
+    /// Factory générée automatiquement à l'aide du fichier GenericFactories.tt
+    /// pour toutes les entités du fichier entity : /CD67.ModeleMVC.Entity/EntityModel.edmx
+    /// </summary>
+	<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#>Factory : Internal.BaseFactory<<#=code.Escape(entity)#>>
+	{
+		/// <summary>
+        /// Constructeur public lié au constructeur de base
+        /// </summary>
+        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
+		<#=Accessibility.ForType(entity)#> <#=code.Escape(entity)#>Factory(Entities dbContext) : base(dbContext) { }
+	}
+}
+	<#
+	}
+fileManager.Process();
+#>
+<#+
+
+public class TypeMapper
+{
+    private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+    private readonly System.Collections.IList _errors;
+    private readonly CodeGenerationTools _code;
+    private readonly MetadataTools _ef;
+
+    public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(ef, "ef");
+        ArgumentNotNull(errors, "errors");
+
+        _code = code;
+        _ef = ef;
+        _errors = errors;
+    }
+
+    public static string FixNamespaces(string typeName)
+    {
+        return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
+    }
+
+    public string GetTypeName(TypeUsage typeUsage)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+    }
+
+    public string GetTypeName(EdmType edmType)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+    }
+
+    public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, string modelNamespace)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+    {
+        if (edmType == null)
+        {
+            return null;
+        }
+
+        var collectionType = edmType as CollectionType;
+        if (collectionType != null)
+        {
+            return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+        }
+
+        var typeName = _code.Escape(edmType.MetadataProperties
+                                .Where(p => p.Name == ExternalTypeNameAttributeName)
+                                .Select(p => (string)p.Value)
+                                .FirstOrDefault())
+            ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+                _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+                _code.Escape(edmType));
+
+        if (edmType is StructuralType)
+        {
+            return typeName;
+        }
+
+        if (edmType is SimpleType)
+        {
+            var clrType = UnderlyingClrType(edmType);
+            if (!IsEnumType(edmType))
+            {
+                typeName = _code.Escape(clrType);
+            }
+
+            typeName = FixNamespaces(typeName);
+
+            return clrType.IsValueType && isNullable == true ?
+                String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+                typeName;
+        }
+
+        throw new ArgumentException("edmType");
+    }
+    
+    public Type UnderlyingClrType(EdmType edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        var primitiveType = edmType as PrimitiveType;
+        if (primitiveType != null)
+        {
+            return primitiveType.ClrEquivalentType;
+        }
+
+        if (IsEnumType(edmType))
+        {
+            return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+        }
+
+        return typeof(object);
+    }
+    
+    public object GetEnumMemberValue(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var valueProperty = enumMember.GetType().GetProperty("Value");
+        return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+    }
+    
+    public string GetEnumMemberName(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var nameProperty = enumMember.GetType().GetProperty("Name");
+        return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+    }
+
+    public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        var membersProperty = enumType.GetType().GetProperty("Members");
+        return membersProperty != null 
+            ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+            : Enumerable.Empty<MetadataItem>();
+    }
+    
+    public bool EnumIsFlags(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+        
+        var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+        return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+    }
+
+    public bool IsEnumType(GlobalItem edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        return edmType.GetType().Name == "EnumType";
+    }
+
+    public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+    }
+
+    public string CreateLiteral(object value)
+    {
+        if (value == null || value.GetType() != typeof(TimeSpan))
+        {
+            return _code.CreateLiteral(value);
+        }
+
+        return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+    }
+    
+    public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
+    {
+        ArgumentNotNull(types, "types");
+        ArgumentNotNull(sourceFile, "sourceFile");
+        
+        var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+        if (types.Any(item => !hash.Add(item)))
+        {
+            _errors.Add(
+                new CompilerError(sourceFile, -1, -1, "6023",
+                    String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+            return false;
+        }
+        return true;
+    }
+    
+    public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
+    {
+        return GetItemsToGenerate<SimpleType>(itemCollection)
+            .Where(e => IsEnumType(e));
+    }
+    
+    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
+    {
+        return itemCollection
+            .OfType<T>()
+            .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+            .OrderBy(i => i.Name);
+    }
+
+    public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
+    {
+        return itemCollection
+            .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+            .Select(g => GetGlobalItemName(g));
+    }
+
+    public string GetGlobalItemName(GlobalItem item)
+    {
+        if (item is EdmType)
+        {
+            return ((EdmType)item).Name;
+        }
+        else
+        {
+            return ((EntityContainer)item).Name;
+        }
+    }
+
+    public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+    
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+
+    public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type);
+    }
+    
+    public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    }
+    
+    public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+        return returnParamsProperty == null
+            ? edmFunction.ReturnParameter
+            : ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+    }
+
+    public bool IsComposable(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+        return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+    }
+
+    public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
+    {
+        return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+    }
+
+    public TypeUsage GetReturnType(EdmFunction edmFunction)
+    {
+        var returnParam = GetReturnParameter(edmFunction);
+        return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+    }
+    
+    public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+    {
+        var returnType = GetReturnType(edmFunction);
+        return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+    }
+}
+
+public static void ArgumentNotNull<T>(T arg, string name) where T : class
+{
+    if (arg == null)
+    {
+        throw new ArgumentNullException(name);
+    }
+}
+
+#>

+ 0 - 28
CD67.ModeleMVC.Factory/TYPE_VIKINGFactory.cs

@@ -1,28 +0,0 @@
-using CD67.ModeleMVC.Entity;
-using System;
-using System.Collections.Generic;
-using System.Data.Entity;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace CD67.ModeleMVC.Factory
-{
-    public class TYPE_VIKINGFactory : Internal.BaseFactory<Entity.EXEMPLE_TYPE_VIKING>
-    {
-        /// <summary>
-        /// Constructeur public lié au constructeur de base
-        /// </summary>
-        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
-        public TYPE_VIKINGFactory(Entities dbContext) : base(dbContext) { }
-
-        /// <summary>
-        /// Ajout d'une surcharge pour trier le retour par défaut
-        /// </summary>
-        /// <returns></returns>
-        public override IQueryable<Entity.EXEMPLE_TYPE_VIKING> getAll()
-        {
-            return base.getAll().OrderBy(i => i.TYPE);
-        }
-    }
-}

+ 7 - 7
CD67.ModeleMVC.MVC/Controllers/TYPE_VIKINGController.cs

@@ -13,7 +13,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         // GET: TYPE_VIKING
         public ActionResult Index()
         {
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             return View(typeVikingFactory.getAll());
         }
 
@@ -24,7 +24,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
             if (typeViking == null)
             {
@@ -49,7 +49,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         {
             if (ModelState.IsValid)
             {
-                TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+                EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
                 typeVikingFactory.add(ref typeViking);
 
                 // Ajout d'un message flash
@@ -68,7 +68,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
             if (typeViking == null)
             {
@@ -86,7 +86,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         {
             if (ModelState.IsValid)
             {
-                TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+                EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
                 typeVikingFactory.update(ref typeViking);
 
                 // Ajout d'un message flash
@@ -104,7 +104,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id.Value);
             if (typeViking == null)
             {
@@ -118,7 +118,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         [ValidateAntiForgeryToken]
         public ActionResult DeleteConfirmed(int id)
         {
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             EXEMPLE_TYPE_VIKING typeViking = typeVikingFactory.getById(id);
             typeVikingFactory.delete(ref typeViking);
 

+ 8 - 8
CD67.ModeleMVC.MVC/Controllers/VIKINGSController.cs

@@ -16,7 +16,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         // GET: VIKINGS
         public ActionResult Index()
         {
-            VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+            EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
             return View(vikingsFactory.getAll());
         }
 
@@ -32,7 +32,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+            EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
             EXEMPLE_VIKINGS viking = vikingsFactory.getById(id.Value);
             if (viking == null)
             {
@@ -59,7 +59,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         {
             if (ModelState.IsValid)
             {
-                VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+                EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
                 vikingsFactory.add(ref viking);
 
                 // Ajout d'un message flash
@@ -78,7 +78,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+            EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
             EXEMPLE_VIKINGS viking = vikingsFactory.getById(id.Value);
             if (viking == null)
             {
@@ -97,7 +97,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         {
             if (ModelState.IsValid)
             {
-                VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+                EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
                 vikingsFactory.update(ref viking);
 
                 // Ajout d'un message flash
@@ -116,7 +116,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-            VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+            EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
             EXEMPLE_VIKINGS viking = vikingsFactory.getById(id.Value);
             if (viking == null)
             {
@@ -130,7 +130,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
         [ValidateAntiForgeryToken]
         public ActionResult DeleteConfirmed(int id)
         {
-            VIKINGSFactory vikingsFactory = new VIKINGSFactory(db);
+            EXEMPLE_VIKINGSFactory vikingsFactory = new EXEMPLE_VIKINGSFactory(db);
             EXEMPLE_VIKINGS viking = vikingsFactory.getById(id);
             vikingsFactory.delete(ref viking);
 
@@ -151,7 +151,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
 
         private void FillSelect(EXEMPLE_VIKINGS viking)
         {
-            TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
+            EXEMPLE_TYPE_VIKINGFactory typeVikingFactory = new EXEMPLE_TYPE_VIKINGFactory(db);
             ViewBag.ID_TYPE = new SelectList(typeVikingFactory.getAll(), "ID", "TYPE", viking.ID_TYPE);
 
             //Chargement d'une liste vide à la création