This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
I have created a base class of T that I will inherits in many other class because I don't want to implement the Find and FindById in each specific class.
Here is want I have made for the function Find:
Public Function FindAll() As Generic.IList(Of Mindscape.LightSpeed.Entity(Of T))
Public Function FindById(ByVal id As Object) As Mindscape.LightSpeed.Entity(Of T)
But when the system try to execute the Find method of UnitOfWork, this raise the following error: "Incorrect syntax near the keyword 'FROM'."
What is wrong with my statements and how can I correct it.
Thank you very much. |
|
|
The problem lies in this call: Find(Of Mindscape.LightSpeed.Entity(Of T)) In Entity(Of T), T is the ID type, *NOT* the entity type. So this is basically asking "get me all entities with (say) integer IDs." And LightSpeed can't do this. LightSpeed requires you to query for a particular type of entity. I think what you're trying to do is query for all entities of type T -- e.g. all Products -- where T is an entity type. To do this, you need to write: Public Function FindAll(Of T)() As IList(Of T As Entity) And similarly for FindById(Of T). Does that meet your requirement? |
|
|
All work fine now. Just for the context, I have created this functions because I have built a web site with asp mvc and I don't want to implement the CRUD operations for each of my screen corresponding to tables in database.
I have created a BaseController(of T) with Create, Edit, Delete and List both Get and Post. For other who want this type of implementation, here is my bunch of code with the help of LightSpeed member. It work now perfectly.
Imports System.Collections.Generic
Thank you very much again. Now I can use of powerful ORM with the RAD advantage adhoc SQL queries. |
|