locked
cannot be inferred from the usage. Try specifying the type arguments explicitly

    Domanda

  • I have a table named Test with an autoincrement field name ID and a varchar field Name.  I am trying to run this code:

     

    DataClasses1DataContext dc = new DataClasses1DataContext();

    Test t = new Test { Name = "Test" };

    dc.Tests.InsertAllOnSubmit(t);

    dc.SubmitChanges();

     

    And am getting this error:

     

    Error 53 The type arguments for method 'System.Data.Linq.Table<testlib.Test>.InsertAllOnSubmit<TSubEntity>(System.Collections.Generic.IEnumerable<TSubEntity>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

     

    I'm just getting started.  Any help would be appreciated.

    lunedì 25 febbraio 2008 03:54

Risposte

  • You made a mistake about insert method.

    take a look at

    dc.Tests.InsertOnSubmit(t);

    InsertAllOnSubmit() is another story!

    Good Luck.

     

    lunedì 25 febbraio 2008 10:24

Tutte le risposte

  • You made a mistake about insert method.

    take a look at

    dc.Tests.InsertOnSubmit(t);

    InsertAllOnSubmit() is another story!

    Good Luck.

     

    lunedì 25 febbraio 2008 10:24

  • InsertAllOnSubmit requires an IEnumerable and you are passing single entity. Either use InsertOnSubmit or pass in a collection (IEnumerable) to this method.

    Code Snippet

    dc.Tests.InsertAllOnSubmit( new Test[] { t } );



    Petar.
    lunedì 25 febbraio 2008 16:53
  • dc.Tests.InsertOnSubmit(t); but not  "dc.Tests.InsertAllOnSubmit(t);"

    martedì 18 marzo 2008 15:52
  •  blue deep wrote:

    You made a mistake about insert method.

    take a look at

    dc.Tests.InsertOnSubmit(t);

    InsertAllOnSubmit() is another story!

    Good Luck.

     

     

    I made EXACTLY the same mistake (Intellisense). lol.

    giovedì 9 ottobre 2008 06:41
  • Error 2 The type arguments for method 'System.Linq.Enumerable.Where<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' 


    code: 

     public IQueryable<usp_SALEINFO_getResult> SearchParcels(string strRange) 
    {
     var predicate = PredicateBuilder.True<usp_SALEINFO_getResult>();

    if (!string.IsNullOrEmpty(strRange))
                {
                  //  query = query.Where((usp_SALEINFO_getResult u) => u.RANGE.Contains(strRange) );
                    predicate = predicate.And(u => u.RANGE == strRange);
                }
     var results = Config .GetCurrentContext().usp_SALEINFO_get().Where(predicate );
     return results;
    }
    giovedì 30 ottobre 2008 18:11
  • Thanks blue deep, it helped me !!
    venerdì 1 febbraio 2013 14:29