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'. "
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.
I get this run time error "no supported translation to SQL".
What i want is to get lists of the posts, and do a small quick calculations of the rating and then sort those from highest to low and take 5 posts only.
I am building a web application in asp.Net 4.0 and entity framework. I am trying to retrieve a list of products based on a collection of id's. I first gather all the id's in a collection and then pass it to the linq query. I am trying to get a functionality similar to the IN clause in SQL. The problem seems to be with the Contains() method in the Linq to entities query. Here is my Linq code:
[Code]....
I got the above Linq to entities method from here: [URL]
When i use the query **var NewMatchs = (from x in entity.matches select x).LastOrDefault();** I got error like this **LINQ to Entities does not recognize the method 'SocialSports.Models.match LastOrDefault[match](System.Linq.IQueryable`1[SocialSports.Models.match])' method, and this method cannot be translated into a store expression.**
I have a GridView and on a row being deleted I trigger the GridView1_RowDeleting sub, but I receive an error "LINQ to Entities does not recognize the method 'System.Web.UI.WebControls.TableCell get_Item(Int32)' method, and this method cannot be translated into a store expression." Code is:
Private Sub GridView1_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting ' The deletion of the individual row is automatically handled by the GridView. Dim dbDelete As New pbu_housingEntities ' Remove individual from the bed. Dim remove_bed = From p In dbDelete.Beds _ Where p.occupant = GridView1.Rows(e.RowIndex).Cells(3).Text _ Where p.room = GridView1.Rows(e.RowIndex).Cells(6).Text _ Where p.building = GridView1.Rows(e.RowIndex).Cells(5).Text _ Order By p.id Descending _ Select p remove_bed.First.occupant = "" dbDelete.SaveChanges() ' Increase number of open spaces in room. Dim update_occupancy = From p In dbDelete.Rooms _ Where p.room1 = GridView1.Rows(e.RowIndex).Cells(6).Text Where p.building = GridView1.Rows(e.RowIndex).Cells(5).Text _ Select p update_occupancy.First.current_occupancy = update_occupancy.First.current_occupancy - 1 dbDelete.SaveChanges() End Sub
The specific line erroring out is: remove_bed.First.occupant = ""
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
I don't know what I'm making wrong.I have a submit button, and on click it should execute the funktion in the code behind, but I get the error that the funktion is undefined.this is my code in the .aspx webform:
I have seen 2 methods to handle error in project. One is using try catch in every method and another is using custom page and error log file .I know both method. Which one is the best method?
I am using Entity Framework to contact my data base. as part of my web code I am using Linq to entities, and I want to determine the number of elements in an anonymous type list. I can't get it to work, I get the exception: "LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression."
var questItem = from chapters in context.TestChapter from questions in context.Question where chapters.ID == int.Parse(Request.QueryString["id"]) where questions.TestChapterID == chapters.ID select questions.ID; int numOfSteps = questItem.Count();
I added the extender and when i tried to add the method this message poped up; Cannot create page method "GetCompletionList" because no Code Behind or codefile was found.
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:
I am using VS 2008 SP1. My also have included CSS Friendly adapter [URL] in my project ( I mentioned this because my GridView Empty data template is not showing when using GridView's CCS Friendly adapter). I have a GridView and a DetailsView. When a record in GridView is selected its details information is shown in the Details View. Type of Data source I am using is ObjectDataSource. My Insert and Update methods works perfectly. It is only the Delete method that is passing null values to the underlying object delete method. My source codes for both the UI, BLL, DAL is shown below
I have an ObjectDataSource that I want to perform updates using a business entity i.e. Type="Object"). Since the values for the entity are within a user control, I have stored a reference to the control in Session and in the updating event, set the new instance to the value of the entity from the user contol property (which also pulls values from the form viaother properties of the control):
Protected Sub MasterDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles MasterDataSource.Updating Dim entity As New Login() Dim accountControl As AccountInfo = TryCast(Session("AccountCtrl"), AccountInfo) entity = accountControl.Entity e.InputParameters.Add("entity", entity) End Sub
My question is, how can I get the update method to pass this entity to the update method in my BLL class? It seems the Update method requires an ID or reference to the original object to use in determining whether any changes have taken place, but I don't really want to do this. In other words, I just want to use the Update event on my ObjectDataSource to pass my entity to the method ("Update") I set as a property and then let this business method handle the update of the data. Shown below, is the BLL update method I want to call:
Public Overloads Function Update(ByVal entity As Login) If entity Is Nothing Then Throw New ArgumentNullException("entity") End If MyBase.Update("UpdateLogin", entity.Username, entity.Password, entity.FirstName, entity.LastName, entity.Role, entity.Region, _ entity.Email, entity.Title, entity.TierID, entity.Street, entity.City, entity.State, entity.Zip, entity.Mobile, entity.Phone, entity.Fax) End Function
When I try to call this as it stands now, I get an error: ObjectDataSource 'MasterDataSource' could not find a non-generic method 'Update' that has parameters: ID, entity. Previously, I'd set up a long list of parameters of basic data types (string, int, boolean), but this is rather cumbersome and I was hoping to use an entity for this (FYI, I also got the same type of error when I tried this approach, but with the ID as the last parameter in the list). Perhaps what I'm doing here is atypical to how the ODS is normally used?? Has anyone done something like this successfully?
I have an application that has JS calling ASMX files to do asyncronous requests, using ASP.NET AJAX.
The problem is that I use always the same "onError" function, and now I don't know how to identify the method that rised the error, and it is giving me a lot of problems to debug errors. The parameter "data" of the onError method does not give enough information, for example:
en System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer) en System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams) en System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) en System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) en System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)
Is there any way to know the webmethod that raised the error?
I want to create a web method that accepts a List of custom objects (passed in via jQuery/JSON). When I run the website locally everything seems to work. jQuery and ASP.NET and everyone is happy. But when I put it on one of our servers it blows up. jQuery gets a 500 error after the ajax request with the response being:
System.InvalidOperationException: EditCustomObjects Web Service method name is not valid. [WebMethod] public void EditCustomObjects(int ID, List<CustomObject> CustomObjectList) [code]...
I have a DetailsView control about a store products.
When I hit the "Edit" button of the DetailsView control, I want to bind a DropDownList to list products categories and select the current product category in it.
I used the method "ModeChanged" to select the current product category like this:
[Code]....
the FindControl method DOES NOT find the "ddlCategory" (returns null) although it's present in the EditTemplateField.
I'm thinking to use "DropDownList's PreRender" event for doing the purpose I aim, but I want to know what is wrong!
I'm having a question about an update method using SQL To Entities. I'm sending an object to the class and i'm updating him sucefully, but i need to specify each property of object instead of update in once. For example
[Code]....
In this case, i'm updating name, age and country sucefully but i want to use instead of update each property one-by-one, something like this:
[Code]....
So, the C = New should fill the C with all New values on properties, but this isn't work. To update an object, i've to update each property individual or can i update all in one like C = New?
I want execute below callback() method after completion of document.getElementById('btnDownload').click(); method . Now callback()executing immediatly. I want wait "Click()" process done then Execute callback(); method.
function LoadPopup() { // find the popup behavior this._popup = $find('mdlPopup'); // show the popup this._popup.show(); // synchronously run the server side validation ... document.getElementById('btnDownload').click(); callback(); } function callback() { this._popup = $find('mdlPopup'); // hide the popup this._popup.hide(); alert("hi"); }
Currently, only GenericOfflineCommentary's ExtractPageData() is firing. How can I modify this to first run OfflineFactsheetBase's ExtractPageData() and then GenericOfflineCommentary's?
edit: I'm trying to avoid having to call base.ExtractPageData() in every implementor.