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
|
In my app I need to obtain values for drop down lists, as the requirements change from form to form, and values are all derived from SQL, I tried to use the FindBySQL<T> option with <T> being a manually created Entity Class. However, I must be doing something wrong as the resulting IList contains the correct number of values, but all the values are null. Can someone please be so kind as to tell me what I am doing wrong. The SQL using in the FndBySQL is similar to: "Select OperatorName As [Value], OperatorName as [Label] from [ResortManager].[dbo].[OperatorDef]" The Entity class I created is as follows: [Serializable] #region Relationships #region Properties Finally the code how I call the FindBySQL<T>: var cmd = ContextsData.DataContext.DataProviderObjectFactory.CreateCommand();
|
|
|
You've got no Id coming back from your SQL. LightSpeed by default expects the ID of the entity to be in a column named Id. Looking at your entity declaration, I notice it doesn't have a Value field, and that the Id type is string. So I'm guessing that the OperatorName/Value column is meant to be the unique Id. If that's correct, you need to either: * Tell the entity that its identity column name is "Value" (using the TableAttribute or the designer Identity Column Name) rather than the default "Id"; or * Change your SQL to alias the OperatorName to "Id" instead of "Value": "SELECT OperatorName AS Id..." If the OperatorName *isn't* the unique ID, then you need to add the Id column to your SELECT statement: "SELECT Id, OperatorName AS Value..." |
|
|
Thanks for the advice. I changed the Value field to be ID, and it works great. Thanks for you help. |
|