C# - The Type Arguments For Method System.Linq.Enumerable.OrderBy Cannot Be Inferred From The Usage

Jan 28, 2011

I'm trying to follow the demo from this link to add a jqGrid to an MVC app.

I have a table named Companies that I'm trying to display in a grid. A Company simply contains an ID and a Name.

I'm running into an error in my controller function:

public JsonResult DynamicGridData(string sortIndex, string sortOrder, int page, int rows)
{
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
var companies = companiesRepository.Companies.OrderBy(sortIndex + " " + sortOrder).Skip(pageIndex * pageSize).Take(pageSize);
//Error here
...
}

I'm getting an error on the line that is calling OrderBy():

The type arguments for method 'System.Linq.Enumerable.OrderBy(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I really have no idea what the error means, and I haven't been able to find an explanation. I'm not sure what is causing this error on a simple OrderBy function.

View 2 Replies


Similar Messages:

ADO.NET :: How To Construct System.linq.enumerable.where

Nov 29, 2010

I have a table "OSTAN" with two columns "ID" (Key index) and "NAME". I am trying to construct a linq query to select the Name for a specific ID. I have not luck trying to construct the where clause. Here what I have so far:

using (XeledsEntities db = new XeledsEntities())
{
string SelectedName = db.Ostans.Name.Where( Ostan=> Ostan.Equals(Request.QueryString["Ostan"])).FirstOrDefault();
}

Can anybody construct this where clause to set the Selected Name?

View 2 Replies

Error While Adding Dynamic Data To An Existing Web Site - The Method 'Skip' Is Only Supported For Sorted Input In LINQ To Entities. The Method 'OrderBy' Must Be Called Before The Method 'Skip'.

Apr 13, 2010

I am creating an Asp.net web site which will support dynamic data. When I am creating a dynamic web site from Scratch (from template in VS) all is working fine. But when I am trying to add dynamic entity (.edmx) file and running the application I am getting following error

"The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. "

View 2 Replies

Find All Child Controls Of Specific Type Using Enumerable.OfType<T>() Or LINQ?

Feb 5, 2010

Existed MyControl1.Controls.OfType<RadioButton>() searches only thru initial collection and do not enters to children.

Is it possible to find all child controls of specific type using Enumerable.OfType<T>() or LINQ without writing own recursive method? Like this.

View 1 Replies

Custom Server Controls :: Using The Generic Type 'System.Collections.Generic.IEnumerable' Requires '1' Type Arguments

Nov 25, 2010

I'm trying to create a control out of a class I found, and one of the overridden functions is the following:

protected override void PerformDataBinding(IEnumerable data)

However, when I try to build the control I'm getting the error as shown in the subject. I've tried searching, and it seems the signature for the original function matches the one I have, and all other solutions I've seen uses the same signature.

View 3 Replies

ADO.NET :: Converting XML Dataset To Be Enumerable For Linq?

Mar 21, 2011

The following code works fine for converting an XML data set to be enumerable for Linq.

'Query webservice for data
Dim propertyInfo As String = myService.GetProperty(userName, password, Acct)
' Create a new DataSet.

[code]...

However, it does not retain the xml tags in the Linq enumerablerable dataset ('newDataSet2"). I don't think I can rely on the array index order as being the same everytime, so this would obviously cause a problem if I'm trying to align the array items up to my database fields. How can I make newDataSet2 retain the XML tags (column headings) to insure I know what data field each array item belongs to?

View 1 Replies

C# - Orderby A HashSet In An Object In Linq?

Jan 7, 2010

I have a pretty complex Linq statement with multiple joins, but am having a problem with an orderby statement.

I think I can reduce the question down a bit, but will expand if needed.

First my object has the following properties:

myObject.ID This is a basic Int

myObject.BrandName This is my HashSet<string>.

I need to sort my Object by the BrandName using the lowest or highest value depending on if I am sorting ascending or descending.

View 2 Replies

Using .net MVC With Sharp Architecture - Looking For Linq Orderby Random

Jul 26, 2010

i'm using Asp.net MVC with Sharp Architecture.

I have this code:

return _repositoryKeyWord.FindAll(x => x.Category.Id == idCAtegory)
.Take(50).ToList();


How can i order by random?

Note: i don't want to order the 50 extracted items, i want order before and then extract 50 items.

View 6 Replies

'Random' Orderby In Webservice Using LINQ To Entities?

Jun 1, 2010

Now I know there is a reason to this odering but my tiny little brain can't get my head around it.I am using a webservice to pull through data to a webp[age and have the following that is so far pulling data through from UUF1:

public string[] GetBuyer(string Memberkey)
{
try

[code]...

View 2 Replies

DataSource Controls :: OrderBy Parameter Type In EntityDataSource?

Feb 26, 2010

I'm playing with an EntityDataSource and specifying a simple order by clause containing one column name, for instance "it.[DNS_NAME]".

When I run the following:

[Code]....

I get an EntitySqlException saying that @sort's type is incorrect. It is expecting a Transient.rowtype that matches one of the columns. What is going on here? Order by parameters don't really have a meaningful type other than a string in my opinion. When I try specifying DbType.String instead of TypeCode.String, the same error is thrown.

The exception:

'@sort' is not a member of type 'Transient.rowtype[(SOFTWARE_DSPL_ID,Edm.Int32(Nullable=True,DefaultValue=)),(COMPUTER_NAME,Edm.String(Nullable=True,DefaultValue=,MaxLength=64,Unicode=True,FixedLength=False)),(DNS_NAME,Edm.String(Nullable=True,DefaultValue=,MaxLength=64,Unicode=True,FixedLength=False)),(DIRECTORATE_NAME,Edm.String(Nullable=True,DefaultValue=,MaxLength=24,Unicode=True,FixedLength=False)),(OS_BROAD_CAT_NAM,Edm.String(Nullable=True,DefaultValue=,MaxLength=25,Unicode=True,FixedLength=False)),(OS,Edm.String(Nullable=True,DefaultValue=,MaxLength=64,Unicode=True,FixedLength=False)),(EQP_TYPE,Edm.String(Nullable=True,DefaultValue=,MaxLength=64,Unicode=True,FixedLength=False)),(EQP_PROP_NO,Edm.String(Nullable=True,DefaultValue=,MaxLength=10,Unicode=True,FixedLength=False))]'
in the currently loaded schemas.

How can I dynamically provide the column name to order by?

View 9 Replies

DataSource Controls :: Linq OrderBy With Nullable DateTime?

May 3, 2010

Is there a way to use the OrderBy command in Linq with a DateTime field using the Date portion only (without the Time Stamp portion) that is nullable such as in the following query?

var query1 = from myTable in MyTable
where myTable.EnteredDate != null
group myTable by myTable.EnteredDate into myOutput[code]....

Since myTable.EnteredDate is a DateTime field that can contain nulls, it does not support the .Date conversion call such as
myTable.EnteredDate.Date

Is there a way to convert the myTable.EnteredDate field into a date only string in the group by portion?

View 3 Replies

DataSource Controls :: Can't Be Applied To Operands Of Type 'int' And 'System.Linq

May 16, 2010

the same problem wuit hme here I wanna to convert from IQureable<int> to int type?

View 2 Replies

ADO.NET :: Error - Can't Implicitly Convert Type 'System.Linq.Iqueryable

Aug 25, 2010

If I have below code, how to make it work as it has below compile error:

Error: cannot implicitly convert type 'System.Linq.Iqueryable<system.data.DataSet> to 'System.Data.Dateset'. An explicit conversion exists.

public DataSet GetProductList()
{
using (var sdatabase = new DatabaseDataContext())
{
IQueryable<DataSet> result = wmsdatabase.ExecuteQuery<DataSet>(@"SELECT productid, productname from product group by productid, productname").AsQueryable();
return result; // Compile error here
}
}

View 1 Replies

Use System.Type.InvokeMember() / Invoke Method Dynamically Using Reflection?

Feb 24, 2011

I understood that we can use System.Type.InvokeMember() to invoke method dynamically using Reflection, but I couldn't get proper example to show how to work on it. Can anyone please explain how to do it in
Visual Studio 2010

Just for practice purpose I have created one class called MathFunctions like below:
namespaceCSHWEB
{
public
class
MathFunctions
{
public
double
SimpleInterest(double
PrinicipalAmount, double
TimePeriod, double RateOfInterest)
{
return
(PrinicipalAmount * TimePeriod * RateOfInterest) / 100.0;
}
}
}

Now,
how can I invoke above method SimpleInterest with its parameters without instantiating the class?

View 1 Replies

Write An Extension Method Or Alternative To Make HtmlTable As Enumerable Row Collection?

Aug 7, 2010

I want to iterate through HtmlTable (Server Side) in ASP.NET 3.5.

foreach (System.Web.UI.HtmlControls.HtmlTableRow trow in someTable)
{
var x = trow.InnerText;
}

I received an error message that "System.Web.UI.HtmlControls.HtmlTable" does not contain a definition for GetEnumerator.

How to write an extension method or alternative to make HtmlTable as enumerable row collection?

View 2 Replies

The Type 'System.Data.Linq.EntitySet`1' Is Defined In An Assembly That Is Not Referenced?

May 26, 2010

I created DBML file inside DLL. compiled it and added a reference to it into a website project.When try from webproject to use the DLL I get error.

[Code]....

View 2 Replies

DataSource Controls :: Unable To Cast Object Of Type 'System.Data.Linq.DataQuery?

Mar 31, 2010

I wanted to delete the record from data but I receive this error "Unable to cast object of type 'System.Data.Linq.DataQuery`1[training_eval.Course]' to type 'training_eval.Course'.

Dim eval_sure = From ev In db.Evaluates Where ev.course_id = indexcourse Select ev.course_id
Dim del_course = From c In db.Courses Where c.Course_id = indexcourse
db.Courses.DeleteOnSubmit(del_course)
db.SubmitChanges()

View 4 Replies

DataSource Controls :: The Type 'System.Data.Linq.DataContext' Is Defined In An Assembly That Is Not Referenced?

May 28, 2010

I have a strange problem. I am adding a LinqDatasource object, and set the context:

[Code]....

Then I get this error:The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

On web.config I already have this:

<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?

View 12 Replies

Forms Data Controls :: Unable To Cast Object Of Type 'System.Web.UI.LiteralControl' To Type 'System.Web.UI.WebControls.TextBox'

Jan 5, 2010

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.

[code]....

View 3 Replies

DataSource Controls :: Unable To Cast Object Of Type '<TakeIterator>d__3a`1[System.Char]' To Type 'System.Collections.IList'

Jan 2, 2010

I want to do paging the API Membership without using the datacontrols, but I get this error "Unable to cast object of type '<TakeIterator>d__3a`1[System.Char]' to type 'System.Collections.IList'." when I do this,

[code]....

View 1 Replies

Forms Data Controls :: Unable To Cast Object Of Type 'System.DBNull' To Type 'System.String'.

Oct 1, 2010

Basically, what I did is that: I have a table in SQL database and some of data fields allow null. I built Objectdatasource through dataset. When I built update page using dataset. It generate the following error before showing the update page correctly. It seems I have issue to retrieve the null value from the database through using objectdatasource through dataset. Any suggestions?An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code

View 6 Replies

Databases :: Retrieving From OdbcDataReader / Unable To Cast Object Of Type 'System.Byte[]' To Type 'System.String'

Feb 16, 2010

I have defined an ODBC Command and ODBCdatareader as follows

OdbcConnection myConnection = new OdbcConnection(connectionString);
OdbcCommand myCommand = new OdbcCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "select UOPGM from GREG.TUSROPTF";
OdbcDataReader myReader;
myConnection.Open();
myReader = myCommand.ExecuteReader();

When I try to retreive from the reader as follows:

while (myReader.Read())
{
string someString = myReader["UOPGM"];
lstNames.Items.Add(someString);
}

I get the following error

Error reading the database. Unable to cast object of type 'System.Byte[]' to type 'System.String'."

I have also tried string someString = (string)myReader["UOPGM"]; to no avail

View 4 Replies

ADO.NET :: Exception Details - System.NotSupportedException - LINQ To Entities Doesn't Recognize The Method

Nov 23, 2010

Im my MVC 3.0 Application, I created a helper like below;

[Code]....

And I used that helper in a linq query as below;

[Code]....

When I fire my app, it gives me the below error. LINQ to Entities does not recognize the method 'System.String GenerateURl(System.String)' method, and this method cannot be translated into a store expression. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: LINQ to Entities does not recognize the method 'System.String GenerateURl(System.String)' method, and this method cannot be translated into a store expression. Source Error:

Line 43: public Blogs GetBlog(string urlstring) {
Line 44:
Line 45: return GetAll().SingleOrDefault(x => BlogUrlGeneration.GenerateURl(x.ArticleTitle).Equals(urlstring));
Line 46: }
Line 47:

İn my blog, the link will be like below; [URL] so I need to set the above urlgenerator class into lambada. How can I do that? What would it take to make that work perfectly

View 4 Replies

DataSource Controls :: Unable To Cast Object Of Type 'System.DBNull' To Type 'System.String'

May 28, 2010

I am trying to write a table output from SQL database to a gridview/ Data List through an Object Data Source. I am a new starter and your help will be useful.

public List<Staff> GetStaff()
cmd.CommandType =
SqlConnection con =
new
SqlConnection(connectionstring);SqlCommand cmd =
new
[code]...

View 4 Replies

Forms Data Controls :: >>Object Of Type 'System.Boolean' Cannot Be Converted To Type 'System.Byte[]'?

Sep 30, 2010

I am trying to upload a picture into database using FormView insertItemTemplate. FormView is bounded by objectdatasource.To upload, I placed FileUpload control inside insertItemTemplate.In table the dataType is image.Error:Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved