Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a web service that returns the list of all the clients.
I can get the list into a gridview by calling the method get all data like this.
test.RH_WebServiceService ligar = new test.RH_WebService();
test.baseList[] data = ligar.getAllData();
The thing is I wanted to filter it by name (for example) I've been reading online and people have said to me that I can just do it like this:
test.baseList[] data = ligar.getAllData().Where(condition);
However I can't get it to work. Do you guys have any ideas?
Assuming you are using Linq then you can just do:
test.baseList[] data = ligar.getAllData().Where(d => d.Name == "John");
The d is a random letter given to the object. Name is what i am assuming your property is called. Although i would recommend creating a method in your service that you pass the name in and get back the filtered data. That way you only return data you need which will improve performance. Something like this:
test.baseList[] data = ligar.getDataByName("John");
Maybe this will help some:
test.baseList[] data = ligar.getAllData().Where(f=> f.field == "value").ToArray();
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am developing job portal which displays different jobs stored in a SQL Server database. I am using ASP.NET and HTML.
I have job_title and unique job_id in my database table. I have created a hyperlink for job_title which is retrieved from database. Now I want to display the details of that particular job on a different page by clicking job_title of that job.
I need job_id for that particular job whose details I want to display on next hyper linked page. The reason for not to use job_title instead of job_id is that job_title is not unique, but job_id is.
Please tell me how to accomplish that or if you have another solution?
You include the value in the query string of the URL.
WebForms:
Something like this:
Click here for details
Then in JobDetails.aspx you would get the value in Page_Load like this:
var jobID = Request.QueryString["jobID"];
Note that the value would be a string, so you'd need to parse it to a numeric type in order to properly use it. int.TryParse() can help with that.
MVC:
Something like this:
Click here for details
Then in the Details action you would have a parameter for the id value:
public ActionResult Details(int id)
{
// Code to get job details and return a View
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
In my database I have a Enum field. I want to put those Enum attributes in a List in C#.
I searched but I couldn't find the answer. Is this possible?
I use a MySqlDatabase. If I want to get the rows from the database I use:
using (var uow = new UnitOfWorkScope<TrackerEntities>(UnitOfWorkScopePurpose.Reading))
In my application I use the Entity Framework
if you loading data in a data reader, however this is sql-server way. But point here is to convert string into enum
var list = new List<YourEnumType>();
var field= reader["DBFieldName"] != DBNull.Value ? reader["DBFieldName"].ToString()
: "";
var myField=(YourEnumType) Enum.Parse(typeof(YourEnumType ), field);
list.Add(myField);
Also have a look at The ENUM Type
You'll need to make a query against the schema table to list the enum values.
SELECT COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = #TABLE_NAME AND
COLUMN_NAME = #COLUMN_NAME
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to put check to validate textbox that input value must not be similar to the values already present in database. Like:
if there is value with text "Hello" in database then user must not be allowed to save value either he writes:
Hello
HELLO
hElLo
HeLLO
Hello etc
I followed this http://www.dotnetperls.com/string-isupper-islower but as i am new to c# so have little confuse that how to match above defined words as all are same words Hello
I typically just convert both values (user input and stored value) to lower case when making the comparison.
Edit: if both values are in .NET, you could use String.Compare(s1, s2, StringComparison.OrdinalIgnoreCase)
Do you need to do this in code? I would suggest that you just make a unique constraint on the column and let the database handle that for you. Depending on the database you are using you may need to do a little additional work to handle the case sensitivity.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I use this code blow in .NET. It works fine. The problem is that I want this audio to play in the root of the website. What changes should I make for this? Thanks
var sample= new System.Windows.Media.MediaPlayer();
sample.Open(new System.Uri( #"D:\voices\1.wav");
sample.Play();
In a web application, this might look something like this:
sample.Open(new System.Uri(Server.MapPath("~/") + #"\voices\1.wav");
I say might because that all depends on whether or not the voices folder exists in the root of the website. Additionally, you should probably leverage Path.Combine instead:
var path = Path.Combine(Server.MapPath("~/"), "voices", "1.wav");
sample.Open(path);
Finally, I don't know what sample is, but the Open method may not work in a website. I'm making the assumption you know what Open does and whether or not it can work in a website.
Use server.mappath("~/") <- that's the filesystem root for your website.
dim path as string = server.mappath("~/") & "/voices/1.wav"
Note that backslashes, for filesystem path, not URI.
Hope it helps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I wish to make all my save transactions at the same time.
I'm using Subsonic 3.0 with active record. I've seen some post with MyClassCollection.Save();
However when i "Run Custom tool" i don't get collections. Obviously i'm missing a trick here?
There is of course another way to do this, using BatchQuery. I had an issue with this. Appreciate any thoughts, as you can see i've very new too all this.
var provider = ProviderFactory.GetProvider("MyProvider");
var batch = new BatchQuery(provider);
foreach (var cdnEntry in cdnEntries)
{
var query1 = new Insert(provider).Into<Clip>
("Author").Values(
cdnEntry.Author);
batch.QueueForTransaction(query1);
}
batch.ExecuteTransaction(); // nothing happens as query count alway = 0
I obviously need to read on the different patterns available for subsonic. Tho i have got the batchquery working. The above code works. I had few silly sql typo's giving me grief.