54 messaggi dal 25 settembre 2010
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
Probabilmente il problema sta nel fatto che usi entità omonime, ma non quelle definite nell'interfaccia. L'interfaccia IContactReader usa le entità POCO del namespace ObjectModel.

Verifica che ci sia l'esatta corrispondenza tra i tipi.

Ciao, Ricky.

Ing. Riccardo Golia
Microsoft MVP ASP.NET/IIS
ASPItalia.com Content Manager
http://blogs.aspitalia.com/rickyvr
http://ricky.aspitalia.com
http://www.riccardogolia.it
54 messaggi dal 25 settembre 2010
rickyvr ha scritto:
Probabilmente il problema sta nel fatto che usi entità omonime, ma non quelle definite nell'interfaccia. L'interfaccia IContactReader usa le entità POCO del namespace ObjectModel.

Verifica che ci sia l'esatta corrispondenza tra i tipi.

Ciao, Ricky.


ADO.NET POCO Entity Generator mi genera un : Model.tt ...errori..Errore1Esecuzione trasformazione: Sovrascrivere il token di sostituzione '$edmxInputFile$' con il nome effettivo del file con estensione edmx da cui si desidera eseguire la generazione.C:\Documents and Settings\Administrator\documenti\visual studio 2010\Projects\Pratica\Pratica.Data\NorthWind.tt11
Devo configuare il codice del model.tt e compilare e mi genera un emdx?

grazie.

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.
Community
UTENTI ONLINE
In primo piano

I più letti di oggi

Media
In evidenza
MISC