lorbaxil 4 settembre 2011 alle 15:00
salve,
sto cercando seguire l'esempio di danielo bocchicchio sul sul libro al capitolo 23:
ho un problema la classe DataService che eredita l'interfaccia IDataService, che a sua volta implementa IDataReader.
Posto i 3 files l'errore me lo da su DataService, sembra non trovi le funzioni nelle interfacce,(errori di battitura controllati,riferimenti controllati)
DataService.vb
Imports Pratica.Core.Common
Imports Pratica.Core.ObjectModel
Public Class DataService
Implements IDataService, IDisposable
Private ReadOnly _context As NorthwindContext
Public Sub New()
_context = New NorthwindContext()
End Sub
Public Function GetCustomers() As List(Of Customer) Implements IDataService.GetCustomers
Return _context.Customers.ToList()
End Function
Public Function GetEmployees() As List(Of Employee) Implements IDataService.GetEmployees
Return _context.Employees.ToList()
End Function
Public Function GetShippers() As List(Of Shipper) Implements IDataService.GetShippers
Return _context.Shippers.ToList()
End Function
Public Function GetSuppliers() As List(Of Supplier) Implements IDataService.GetSuppliers
Return _context.Suppliers.ToList()
End Function
Public Function SearchByFirstLetter(ByVal firstLetter As Char) As List(Of Contact) Implements IDataService.SearchByFirstLetter
Dim letter As String = firstLetter.ToString()
Dim customers = Me.GetCustomers().Where(Function(c As Customer) c.CompanyName.StartsWith(letter, StringComparison.CurrentCultureIgnoreCase)).Select(
Function(c As Customer) _
New Contact With {
.ContactID = c.CustomerID,
.CompanyName = c.CompanyName,
.FirstName = c.ContactName,
.Phone = c.Phone,
.Type = ContactType.Customer
})
Dim employees = Me.GetEmployees().Where(Function(e As Employee) e.LastName.StartsWith(letter, StringComparison.CurrentCultureIgnoreCase)).Select(
Function(e As Employee) _
New Contact With {
.ContactID = "EM" & e.EmployeeID.ToString("000"),
.CompanyName = e.LastName,
.FirstName = e.FirstName,
.LastName = e.LastName,
.Phone = e.Phone,
.Type = ContactType.Employee
})
Dim shippers = Me.GetShippers().Where(Function(s As Shipper) s.CompanyName.StartsWith(letter, StringComparison.CurrentCultureIgnoreCase)).Select(
Function(s As Shipper) _
New Contact With {
.ContactID = "SH" & s.ShipperID.ToString("000"),
.CompanyName = s.CompanyName,
.Phone = s.Phone,
.Type = ContactType.Shipper
})
Dim suppliers = Me.GetSuppliers().Where(Function(s As Supplier) s.CompanyName.StartsWith(letter, StringComparison.CurrentCultureIgnoreCase)).Select(
Function(s As Supplier) _
New Contact With { _
.ContactID = "SU" & s.SupplierID.ToString("000"), _
.CompanyName = s.CompanyName, _
.FirstName = s.ContactName, _
.Phone = s.Phone, _
.Type = ContactType.Supplier _
})
Return customers.Union(employees).Union(shippers).Union(suppliers).OrderBy(Function(c As Contact) c.CompanyName).ToList()
End Function
Public Sub CreateContact(ByVal contact As Contact) Implements IDataService.CreateContact
' ...
End Sub
Public Sub UpdateContact(ByVal contact As Contact) Implements IDataService.UpdateContact
' ...
End Sub
Public Sub DeleteContact(ByVal contact As Contact) Implements IDataService.DeleteContact
' ...
End Sub
'riporto errore su questo listato: Errore3Class 'DataService' deve implementare 'Function GetCustomers() As 'System.Collections.Generic.List(Of Customer)' per l'interfaccia 'Core.Common.IContactReader'(stesso errore per tutte le funzioni)
IdataService.vb
Imports Pratica.Core.Common
Public Interface IDataService
Inherits IContactSearch, IContactManager, IContactReader
End Interface
IContactReader.vb
Imports Pratica.Core.ObjectModel
Namespace Common
Public Interface IContactReader
Function GetCustomers() As List(Of Customer)
Function GetEmployees() As List(Of Employee)
Function GetShippers() As List(Of Shipper)
Function GetSuppliers() As List(Of Supplier)
End Interface
End Namespace
dove sbaglio? la soluzione originale funziona, eppure è identica a parte il nome.
ciao grz