By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,967 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,967 IT Pros & Developers. It's quick & easy.

Explicit Data Typing

KodeKrazy
P: 32
When I try to use LINQ to SQL, I get the following error:

"Data type(s) of the type parameter(s) in method 'Public Sub InsertAllOnSubmit(Of TSubEntity As TEntity)(entities As System.Collections.Generic.IEnumerable(Of TSubEntity))' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error."

Where do I need to specify the data types explicitly? In my
Expand|Select|Wrap|Line Numbers
  1. DB.Items.InsertAllOnSubmit(newCatItem)
statement, or where I declare the variables? (Already typed everything to match my SQL DB in the variable declarations, so if that's correct, I did something wrong)

KK
May 9 '08 #1
Share this Question
Share on Google+
4 Replies


daniel aristidou
100+
P: 491
Ok i think the isue is the newcatitem
Can u post the code that sets this variable?
May 9 '08 #2

KodeKrazy
P: 32
Expand|Select|Wrap|Line Numbers
  1. Option Infer On
  2. Option Strict On
  3.  
  4. Imports System.Collections.Generic
  5. Imports System.Data
  6. Imports System.Data.Linq
  7. Imports System.Data.Linq.Mapping
  8. Imports System.Data.Linq.SqlClient
  9. Imports System.IO
  10. Imports System.Linq
  11. Imports System.Linq.Expressions
  12. Imports System.Reflection
  13.  
  14. Public Class clsLINQ_Procs
  15.   Private DB As CatDataClassesDataContext
  16.   Public pag As String    ' Page
  17.  
  18.   Public Function AddCat() As Boolean
  19.  
  20.      pag = CType(frmMain.dgvItems.Rows(i).Cells.Item(38).Value.ToString, String)
  21.  
  22.      Dim newCatItem = New Item With {.Page = CType(pag, String)}
  23.  
  24.      DB.Items.InsertAllOnSubmit(newCatItem)
  25.      DB.SubmitChanges() 
  26.  
  27.      Return AddCat=True
  28.  
  29.   End Function
  30. End Class
  31.  
  32.  
There are quite a few other variables but in the interest of simplicity all the other variables are typed and declared in the same manner.

TIA,

KK
May 9 '08 #3

KodeKrazy
P: 32
Expand|Select|Wrap|Line Numbers
  1. Option Infer On
  2. Option Strict On
  3.  
  4. Imports System.Collections.Generic
  5. Imports System.Data
  6. Imports System.Data.Linq
  7. Imports System.Data.Linq.Mapping
  8. Imports System.Data.Linq.SqlClient
  9. Imports System.IO
  10. Imports System.Linq
  11. Imports System.Linq.Expressions
  12. Imports System.Reflection
  13.  
  14. Public Class clsLINQ_Procs
  15.   Private DB As CatDataClassesDataContext
  16.   Public pag As String    ' Page
  17.  
  18.   Public Function AddCat() As Boolean
  19.  
  20.      pag = CType(frmMain.dgvItems.Rows(i).Cells.Item(38).Value.ToString, String)
  21.  
  22.      Dim newCatItem = New Item With {.Page = CType(pag, String)}
  23.  
  24.      DB.Items.InsertAllOnSubmit(newCatItem)
  25.      DB.SubmitChanges() 
  26.  
  27.      Return AddCat=True
  28.  
  29.   End Function
  30. End Class
  31.  
  32.  
There are quite a few other variables but in the interest of simplicity all the other variables are typed and declared in the same manner.

TIA,

KK
Not sure why it is putting all the space in the word "Value" but it's not there in my code. Just an FYI... kk
May 9 '08 #4

KodeKrazy
P: 32
Still getting the error, still don't know why...
May 13 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.