Get VB Anonymous Methods Working - Querying Lists?

Jul 1, 2010

I am trying to get my code working as per the instruction on [URL]

Public Delegate Function PredicateWrapperDelegate(Of T, A)(ByVal item As T, ByVal argument As A) As Boolean
Public Class PredicateWrapper(Of T, A)
Private _argument As A
Private _wrapperDelegate As PredicateWrapperDelegate(Of T, A)
Public Sub New(ByVal argument As A, _
ByVal wrapperDelegate As PredicateWrapperDelegate(Of T, A))
_argument = argument
_wrapperDelegate = wrapperDelegate
End Sub

Private Function InnerPredicate(ByVal item As T) As Boolean
Return _wrapperDelegate(item, _argument)
End Function

Public Shared Widening Operator CType( _
ByVal wrapper As PredicateWrapper(Of T, A)) _
As Predicate(Of T)
Return New Predicate(Of T)(AddressOf wrapper.InnerPredicate)
End Operator
End Class

Then I have the function which I have modified to use my department id variable (did)

Function DidMatch(ByVal item As ListDataItem, ByVal did As Integer) As Boolean
Return item.AssigneddepartmentID.Equals(did)
End Function

Then I try to call it from my code:

Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of Integer, Integer)(Did, AddressOf DidMatch))

I then get an error on DidMatch ... Error Method 'Public Function DidMatch(item As DeptMenuData, did As Integer) As Boolean' does not have a signature compatible with delegate 'Delegate Function PredicateWrapperDelegate(Of Integer, Integer)(item As Integer, argument As Integer) As Boolean'.

View 1 Replies


Similar Messages:

C# And Anonymous Types - Iterate Through A DataTable While Manually Building An Anonymous Type

Jan 18, 2010

I am currently implementing a client-side paging solution using ASP.NET, jQuery and JSON.

I have been following the excellent article from encosia: http://encosia.com/2008/08/20/easily-build-powerful-client-side-ajax-paging-using-jquery/

In my Web Method I retrieve my data from the database as a DataTable:

DataTable categoryProducts = ProductViewerAccess.GetCategoryProducts
("AA", 4, 0, Page.ToString(), out howManyPages, "FALSE", 0, "CostPrice", "asc", destinationList);

I then retrieve the data from the DataTable into an anonymous type:

var feeds =
from feed in categoryProducts.AsEnumerable()[code]....

This all works great.

However, I would like to extend the code to perform some evaluation checks (e.g., check that various columns in the DataTable are not NULL) and other pre-processing (e.g., call various functions to build the image URL based on the image ID - which is another column in the DataTable not shown in the code fragment) before I return the resulting rows of the DataTable as an anonymous type to the client-side.Basically, I want to iterate through the DataTable, perform the evaluation checks and pre-processing, while building my anonymous type manually as I go. Or maybe there is a better way to achieve this?

View 2 Replies

MVC : AJAX Methods - Code Is Not Working

Jul 22, 2010

Below is some code. The save() method was pre-existing. I added the saveRanking() method. When I walk through the code, it hits the method, but then it just bails out of it. No exception (that I can see). Do I need that function(data) part?
Code:
function save() {
$.post(
"/Applications/SaveStatus",
[code]....

View 1 Replies

AJAX :: Methods Not Working On Windows Server 2008?

Apr 15, 2010

I have created a web aplication in the following environment Visual studio 2008, IIS 5.0 & OS:Windows XP. It is working fine in my local system. But when I host this application on the server some of the AJAX methods are not working.

The server environment: They have installed Microsoft .Net framework 3.5, IIS 7.0 & OS:Vista.

I am using a text box in that application. When a user types any character say 'a' a div will be opened below the text box displaying all the cities starting with the character 'a'.

for example this is code where I have written the Ajax method

[Code]....

I am calling this Ajax method in the source file through javascript, below is the code

[Code]....

The ajax method which was written in the .cs file returns the response.value correctly in my local system.But in the server the Ajax method is not returning the response.value.

View 1 Replies

MVC :: 3 Beta And Virtual Directory With Different Auth Methods Not Working

Oct 17, 2010

when I upgraded my root website from ASP.NET MVC 3 Preview 1 to the new Beta 1. I am using RavenDB, which needs to run as a virtual sub-application with Windows authentication instead of Forms authentication. I had raven working like described above just fine in preview 1, but with beta 1, now it won't work. It looks like no matter what I try, the membership provider system for my root website is redirecting me back to the login page, even though I've set my RavenDB virtual directory to use windows authentication and cleared out the membership and roles providers in it's web.config. I guess MS changed something to do with

either routing or authentication between preview 1 and beta 1. If anyone else sees this problem and knows how to fix it, I would be in your debt. I would guess that the easiest way to recreate the problem would be to create a new ASP.NET MVC 3 Beta 1 root website, then add a virtual directory marked as an application. See if you can get the root site to use the forms auth provided by default, but have the virtual directory use windows auth, denying all users but a specific one of your choosing. I can't seem to get this scenario working in the beta like I did in the preview.

View 3 Replies

C# - Methods With Nullable Types Not Working In ASMX Web Service Using GET

Mar 14, 2011

I have an ASMX Web Service set up to use the HTTP GET method. Simple methods which take basic String and Int parameters are working ok, and I can call MyService.asmx/MethodName?Param=Value and get a response back in XML.

However, when I have a method which has a nullable Int (i.e. int?), I get this error:

< Method Name > Web Service method name is not valid.

The error message is confusing, as the method does exist, just not in the GET scope. I presume this is because a nullable type is too complex to be passed via the URL, but I can't find any documentation or SO posts on this.

I appreciate that complex types like Lists or custom classes etc will not work using GET, but I would have assumed that a simple nullable int or nullable datetime could be handled natively, simply by detecting whether it was omitted from the URL. Guess it's not that simple!

View 1 Replies

Using Extension Methods In Static Methods On Extended Classes?

Aug 16, 2010

I have an extension method as follows:

public static class PageExtensions
{
public static int GetUserId(this Page targetPage)
{
var user = Membership.GetUser(targetPage.User.Identity.Name);
return (int)user.ProviderUserKey;
}
}

Now in a page I need to use this method in a static WebMethod, so I have added another 'extension method' to PageExtensions:

public static int GetUserId()
{
return (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
}

and I call it as follows in my WebMethod: PageExtensions.GetUserId()

View 1 Replies

Web Forms :: How To Change This Methods In To Use Dictionary Or Extension Methods

Jul 23, 2010

public class CacheHelper { /// <summary> /// Removes object with the specified key. /// </summary> /// <param name="key">The key.</param> [code]....

I have this methods for caching..I need to change this methods to use in aDictionary<string,object>

How do I need to change this code Because I am new to asp.net I am still learning..

View 12 Replies

ToList And Querying Multiple Entities?

May 13, 2010

I have the following code for the SelectedIndexChanged event of a drop down list. This works fine as it is but this entity has a relationship to another entity (Genre). if i change the select statement to { m, m.Genre.MovieGenre }).ToList(); it doesnt work as contains anonomyous types.

[code].....

View 1 Replies

DataSource Controls :: Querying SQL Database?

Jan 10, 2010

I have an SQL database which I wish to query, I have the queries set out and working using the SQLDataSource Control.Is there any way of using web methods to query an SQL Database.I realize this may not be ideal when the SQLDataSource control offers such functionality but it is for a piece of college work and I am not entirely sure which way they want it to work, as all it says is to "Implement a client application and a set of web services".

So is it possibile to use a WebMethod to perform SQL based queries or queries which are not SQL based and if so how do you go about creating them?

View 4 Replies

DataSource Controls :: Querying One To Many Relationship DB C#?

Mar 23, 2010

I have a database which contain job ads/ I have one table "dbo.tbl_jobadvert" which contains the ad itself and another table "dbo.tbl_jobFiles" which contains the path of the documents uploaded in relations to the job advert ( application form, job description, etc )

[Code]....

View 1 Replies

DataSource Controls :: Querying A Databse From Within A VB Sub?

Jul 2, 2010

I'm using Visual Web Developer 2010 Express with SQL server 2008 Express and I'm wondering if it is possible to query the database from within a VB subroutine located within pagename.aspx.vb, rather than just using the asp databound controls on the main page ?

I want to do something like this in the page load routine:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim username As String
username = GetUserName() 'calls function to get current username
Now connect to database and perform SQL command (SELECT FirstName FROM dbo.USERS WHERE UserName = username)
Assign the retuned data to a label: lblFirstName.Text
End Sub

Is it possible ?

View 7 Replies

Mobiles :: Developed A Data Querying Application For The Web

May 3, 2010

I have developed a data querying application for the Web, this is in a host. What steps should I take if I want this application can also be used with mobile devices.

View 3 Replies

C# - Querying Database Using The Same Date Does Not Return Data?

Mar 2, 2010

I have a little problem with a query. I'm selecting data using the between command, But when I select the initial date equal to the final date the query doesn't show data.I know that the problem is the format. In my database I got something like this:2009-05-22 15:32:52.000. But when I send the date parameter from ASP.NET Page I sent only the Date (2009-05-22).So, I want to fix this thing. I cannot change the Datetime inside the database.I was thinking adding 1 day to the final date, So when the user select the same date I change the range behind the scene and then show the data. What do you think?

View 8 Replies

SQL Server :: Querying SQL Table For Conflicting Values?

Mar 8, 2011

I have this table in SQL that I'm trying to do some comparison work with Ok, onto the schema. It's like this:

[Code]....

Now, what I want to do is query my database in this manner:Display any records that conflict only Non-priority conflict based on: priority based on the time of day

[Code]....

View 4 Replies

Querying Remote Data Stores From Application?

Dec 5, 2010

I am writing an ASP.NET application that suppose to connect to many different data stores and query them for data. Each data store contains different data: it can be an SQL DB, an XML file, or anything that can store data. The result is always an XML.

The remote data stores expose a WCF service (which I will also implement) that will allow me to query the data store and return the results.

My question is: how exactly should I implement the querying mechanism? Should I define my own query language?

View 1 Replies

C# - Querying LDAP For Usergroup Of Specific User?

Mar 16, 2011

I have to check usergroups of LDAP Active Directory for a specific user in C#. Mean I pass this username to a method and it returns me list of group from that user belongs. Im Searching alot But Everytime get new error.

LDAP Path: 192.168.1.4
Domain Name: Arslan
UserName: ArslanP
Password: testad

View 2 Replies

C# - Querying Multiple Databases Using Distributed Web Services?

Feb 5, 2011

I have a quick question about best practices and especially expected performance for the following scenario:

If I want to query data from multiple servers that contain schematically identital sql databases, would having each server provide a web method that a single client application can consume be an appropriate (and relatively fast) solution?

The data just needs to be consolidated on the client end, where several web methods would have to be consumed serially (or in parallel?) to provide the data to the client. Each server would also be implementing Entity Framework as an ORM.

Performance is my main concern here, would it turn out excessively slow as we start to scale up to more and more servers?

View 2 Replies

Security :: Not Extending MembershipProvider Class And Putting All This Methods In Some Unique Class And Call Its Methods Then?

Sep 16, 2010

I am beginner in web applications development. I started one little project and host it on source forge "https://homoco.svn.sourceforge.net/svnroot/homoco". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:

1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.

2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.

3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.

I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.

View 3 Replies

DataSource Controls :: Querying Across Associations With Listview And Linqdatasource?

Feb 12, 2010

With the gridview I can create a template field to query across associations but I don't see how its possible to do that with the listview (?). I tried to create associations in the eval fields

(ie productId.Brand) where productId is in the Reviews table and is associated with the Products table - and Brand is a member of the Product table but it was no go?

[Code]....

<b>Title:</b> <%# Eval("Title") %>

View 4 Replies

DataSource Controls :: Querying & Updating Data From Dataset?

Mar 15, 2010

I'm hoping someone can point me in the right direction. I will be as detailed as I can in explaining the issue;I have a dataset I have instantiated in a class file (vb.net), and fill the data succesfully. That data is then dumped into an excel file. What I need to do is to go through all the data in the dataset, and directly update the database, changing a "status" column from "pending" to "processing" based on the store number. As I am new to datasets (relatively speaking, of course), I am not quite certain how to accomplish this task. Below is the code I have so far:

[Code]....

If anyone could provide sample code to use, or could provide a quick bit of code I could just copy and paste in and test,

View 1 Replies

Incorrect Component When Querying Immediately After Insert Using NHibernate?

Apr 5, 2010

I have the following mapping for my table in MySql:

<class name="Tag, namespace" table="tags" >
<id name="id" type="Int32" unsaved-value="0">
<generator class="native"></generator>
</id>

[Code]....

As you see the record_dates property is defined as a component field of type DateMetaDate. Both created_at and updated_at fields in 'tags' table are updated via triggers. Thus I can insert a new record like such:

var newTag = new Tag()
{
name = "some string here"
}
Int32 id = (Int32)Session.Save(tag);
Session.Flush();
ITag t = Session.Get<Tag>(id);
ViewData["xxx"] = t.name; // -----> not null
ViewData["xxx"] = t.record_dates.created_at; // -----> is null

However when querying the same record back immediately after it was inserted the record_dates field ends up null even though in the table those fields have got values.

why the Session.Get ignores getting everything back from the table? is it because it caches the newly created record for which the records_dates is null? If so how can it be told to ignore the cached version?

View 3 Replies

Forms Data Controls :: Noob Stuff: Querying Any Value From SQL Database?

Jan 10, 2011

I'm trying to create a search page that searchs one specific table in the entrie datbase.Basically someone writes what they want in a textbox in search.aspx, they click the search button, and it takes them to another page called search_results.aspx, carrying the inputted text along with it. What search results is supposed to do is at page load, its supposed to query the entire database for all values that are LIKE the text in the querystring, then transport the entire value set of each row that has a field matchign the query string, and then it's supposed take those values and put them in a template that presents them in the way that I want.

The only thing out of all that that I don't know how to do is write the code for taking the querystring and putting it up against all the values in the database like that. I know that you can find a value in a specfic comlumn, i.e.

SELECT Column1, Column2
FROM Table1
Where Column1 = 'blah1', 'blah2'

but how do you write it so that it looks at all the columns for 1 or 2 specfic values (the querystring), and then it returns the entire for each time it finds them?

View 7 Replies

ADO.NET :: Querying Derived Types But Only With Specific Values / LINQ To Entities?

Nov 5, 2010

I can't find the answer to this easy question, because I don't know the terminology I am looking to use. I have 2 tables, one that is a Users Table, and another (UserProfiles) that extends the Users table to include more info, like Age, Sex, Weight, etc.I am using the Entity Framework as my model, and the UserProfiles inherits from the Users table on a 1:1 basis.

All I need to do is the learn the syntax, that allows LINQ to Entities to query only some of the data from UserProfiles. For example, maybe I only need Sex and Weight, but not Age.

[Code]....

View 4 Replies

Web Forms :: Querying Menu Items MenuItem NavigateUrl In MasterPage.Master?

Mar 26, 2010

How do you generate a list of NavigateUrl s of a static Menu on the MasterPage.Master ?

The following code just returns the first level of Menu NavigateUrl items.

The code will return Home.aspx but not "FAQ.doc" and "Trouble Shooting.doc".

[Code]....

View 4 Replies







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