Cześć,
mam sobie taki interfejs ITypeRepository:
using MojSerwisPism.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MojSerwisPism.Repositories
{
/// <summary>
/// Interfejs repozytorium typu.
/// </summary>
public interface ITypeRepository : IRepository<Type>
{
/// <summary>
/// Pobranie wszystkich typów zleceń.
/// </summary>
/// <returns>Typy zleceń</returns>
IQueryable<Type> GetAllTypes();
/// <summary>
/// Pobranie typów zleceń po identyfikatorze.
/// </summary>
/// <param name="id">Identyfikator typu zlecenia.</param>
/// <returns>Typy zleceń o podanym identyfikatorze.</returns>
Type GetTypeById(int id);
/// <summary>
/// Pobranie wszystkich typów komentarzy.
/// </summary>
/// <returns>Typy komentarzy.</returns>
IQueryable<CommentType> GetAllCommentTypes();
/// <summary>
/// Pobranie typów komentarzy po identyfikatorze.
/// </summary>
/// <param name="id">Identyfikator typów komentarzy.</param>
/// <returns>Typy komentarzy o podanym identyfikatorze.</returns>
CommentType GetCommentTypeById(int id);
}
}
Który to dziedziczy z interfejsu IRepository:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MojSerwisPism.Repositories
{
/// <summary>
/// Interfejs bazowy repozytorium.
/// </summary>
/// <typeparam name="T">Typ repozytorium.</typeparam>
public interface IRepository<T>
{
/// <summary>
/// Operacja dodawania.
/// </summary>
/// <param name="element">Dodawany obiekt.</param>
void Add(T element);
/// <summary>
/// Operacja usuwania.
/// </summary>
/// <param name="element">Usuwany obiekt.</param>
void Delete(T element);
/// <summary>
/// Zapisanie zmian.
/// </summary>
void SaveChanges();
}
}
Chcę, żeby ten pierwszy interfejs czyli ITypeRepository dotyczył klasy z modelu TypeModel.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace MojSerwisPism.Models
{
[MetadataType(typeof(TypeMetaData))]
public class Type
{
public Type()
{
this.Orders = new HashSet<Order>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Order> Orders { get; set; }
}
public class TypeMetaData
{
[Required(ErrorMessage = "Nazwa jest wymagana.")]
[Display(Name = "Nazwa")]
public string Name { get; set; }
}
}
Natomiast problem jest z kompilacją kodu bo wywala mi, że Type nie jest jednoznaczną referencją w tym fragmencie z interfejsu ITypeRepository:
public interface ITypeRepository : IRepository<Type>
Błąd to:
Error 2 'Type' is an ambiguous reference between 'MojSerwisPism.Models.Type' and 'System.Type' C:\Users\Bartek\Documents\Visual Studio 2012\Projects\MojSerwisPism\MojSerwisPism\Repositories\ITypeRepository.cs 13 52 MojSerwisPism
Jak to ogarnąć bo już nie mam pomysłów?
Pozdrawiam.