DataSource Controls :: Linq Query With OrElse?

Apr 7, 2010

I'm having a problem with a Linq query where is executing the second half of an OrElse even though the first half evaluates to true.

[Code]....

When Manufacturer is null, I get a NullReferenceException. The "Manufacturer.Trim()" should never be executed, because the first half of the OrElse evaluates to true. Just to test it out, I also tried this:

[Code]....

This actually works fine... Manufacturer.Trim() is never executed, and I get no error. Why is the Trim() statement being executed in the first case? If Manufacturer is null, then it shouldn't be.

View 4 Replies


Similar Messages:

DataSource Controls :: How To Convert Sql Query Into Linq Query

Mar 10, 2010

select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid

View 5 Replies

DataSource Controls :: Query Using Linq To Sql?

Jun 25, 2010

I´m using Linq to Sql in my asp.net application, but the problem is:I have a query like this:

[Code]....

My query is not returning anything, how do I do to get this?my problem is with this interval I need to have.

View 2 Replies

DataSource Controls :: One Linq Query With Two Db Connection?

May 31, 2010

I want to use from two db connection in one linq query

My sample is:

int a=1;
if(a==1)
DataClasses1DataContext1 db = new DataClasses1DataContext1();
else
DataClasses1DataContext2 db = new DataClasses1DataContext2();
var q =
from c
in db.F_Groups
select c;

In this code a=1 so db connection is DataClasses1DataContext1

I want if a=2 then db connection = DataClasses1DataContext2

but this code is error.

db connections is completely same but in two deferent class a db connection is sql and another is oracle

View 4 Replies

DataSource Controls :: How To Convert Sql Query To LINQ

Feb 13, 2010

How can I convert this sql query to LINQ ?

[code]...

View 1 Replies

DataSource Controls :: Linq To Sql Query / Zip Codes?

Feb 18, 2010

Im doing thing profile, zip code thing on my site. One table has a list of zipcodes and in the other is a profile and there they keep what zip code they entered. I already have the radius code but idk how to get a list of all the profiles in a radius.I'm going to store the zip codes that come back from the zip code table in a arraylist and put it in a session state so i don't have to keep getting the same thing over and over again. The problem is i don't know how to write the linq to sql query to take the arraylist of zip codes and look up all the users that have that as there set zip code in there profile.

View 1 Replies

DataSource Controls :: Return First Value From A Linq Query?

Mar 12, 2010

Is there a way opf getting the first value from a linq query so for example

[Code]....

View 2 Replies

DataSource Controls :: Add A New Item To A LINQ Query?

May 13, 2010

So I'm trying to add a single item to a query I wrote. The query is then pass to the e.Result of a LinqDataSource_Selecting event. This datasource is being used by a dropdown list and label in a listview.

I am trying to add a "New" field to the end of the list.

Currently I have this working, but it seems like a really messy solution. First I make a class with the fields I need:

[Code]....

Then I build the query:

[Code]....

Then a second list and query with the new value:

[Code]....

Finally, I union the two and set the e.Result:

[Code]....

View 5 Replies

DataSource Controls :: Retrieve Value From LINQ Query?

Mar 20, 2010

I need to know how to extract the result of the attempted LINQ query below and set it equal to the strFile variable.Everything Intellisensed OK here but ine 5 shows a syntax error at the parenthesis.

[Code]....

View 12 Replies

DataSource Controls :: Random Results From A LINQ To SQL Query?

Jan 23, 2010

I have this LINQ query:

var agnts = (from a in db.agents select new { a.userid, a.name }).Take(10);

How can I get randomly get 10 records from my agents table?

I have tried:

agnts = agnts.OrderBy(n => Guid.NewGuid());

but this doesn't seem to do anything.

View 5 Replies

DataSource Controls :: SQL Query Re-Write In Linq To Entity?

Jan 26, 2010

Need to figure out the correct way to do a simple SUM function in Linq, but also manipulate one of the feilds coming back by doing a Substring on it, here is the original SQL query:

[Code]....

View 1 Replies

DataSource Controls :: LINQ And C# - Accessing More Then 2 Tables In A Query

Apr 23, 2010

As the title sugests, I am missing a (basic?) concept as I teach myself asp.net, linq, and C#. It has been awhile since I've done anything object oriented, so I don't know how much that is impacting this gap in my understanding. Anyhow, here is what I am trying to do. I have three SQL Server tables: PERSON, POSITION, AREA. There is a 1 to many relationship between PERSON and POSITION, and a 1 to 1 relationship between POSITION and AREA. Given the following code I verify who the person is who has logged into the browser:

[Code]....

I want to be able to return all of the AREAs the person is able to access, based on the position they currently hold. I am able to easily do this in a SQL Server query, and I am sure I can do this with a SQL stored procedure once I pass the EMPLOYEE_ID to the procedure. However, I would rather do this in the page_load event, and load the returned results into gridview1 for the viewer. The issue I am running into is in building the LINQ query. When I try to build it, I can only get access to two of the three tables, depending on which table I select with db. Is it possible to access all three tables in the same query?

View 10 Replies

DataSource Controls :: Finding A Field In A Linq Query

Mar 1, 2010

I have a field name as a string and i want to find it in a linq query. so something like this

[Code]....

View 3 Replies

DataSource Controls :: Linq To Sql Query / Could Not Translate Expression?

Mar 26, 2010

I have the following LINQ query which works correctly:

[Code]....

The following query, however causes an error:

[Code]....

"Could not translate expression 'Table(t_f2f_event).Where(e => ((e.EVT_START_DATE > Invoke(value(System.Func`1[System.Nullable`1[System.DateTime]]))) && (e.EVT_START_DATE < Invoke(value(System.Func`1[System.Nullable`1[System.DateTime]])))))' into SQL
and could not treat it as a local expression."

View 2 Replies

DataSource Controls :: Calling Function In Linq Query

Apr 8, 2010

I have a problem here.In my database I store member status in 1 and 0, when it come to my gridview I need change 1 and 0 to active and inactive. My company is using Linq, so I must follow. I wrote in this style, I calling a changeToWord() function to change 1 and 0 to active and inactive.

var q=from a in db.members
select new{
mem_name=a.name,
status=ChangeToWords(a.status)
}

It compiles with no error, but when I execute the page, it prompt out a error message to me.

View 3 Replies

DataSource Controls :: Can Get Two Tables In Only One Query With LINQ To Entities

May 20, 2010

can get two tables in only one query with LINQ to Entities

Code for example:

[Code]....

View 4 Replies

DataSource Controls :: View The LINQ To DataSet Query?

Feb 23, 2010

I'm trying to find an easy way to view the query that has been generated as part of the LINQ to DataSet syntax in my application. I found Scott Gu's blog and his creation of the Linq to SQL Debug Visualizer but it doesn't appear to work for my application. I am using OracleClient if that is important.

My next step is to simply configure the Oracle Manager for the database to see the query but I can't believe there's not an easy way to view this generated query.

View 3 Replies

DataSource Controls :: Using IF Statements In LINQ Insert Query?

Jun 7, 2010

I tried to find a LINQ section on this forum, but couldn't, so I'll post this here since is deals with LINQ, C#, MVC, SQL Server, and well...just about everything.

Here's the details....My Application is an ASP .Net MVC 1.0 app, using C# 3.5, SQL Server 2005 Std, and LINQ to Entity.

In my View, I have numerous Html.CheckBox controls, they get passed to my Controller as a string collection via a JQuery Ajax call. The values of each checkbox are seperated by a comma(,). I then Split the string, to get the individual values. The overall purpose to to allow users to build a custom report with only the data elements they have checked the boxes for. Here is my controller:

[Code]....

The part that I am having a problem with is that I only want to Insert the data elements into my DB table for the ones that the user has selected the checkbox for. So, for example, I'd like to do something like this:

[Code]....

I don't know if there is a LINQ switch statement in which I can access outside variables and the columns of the table, or any thing like that.

View 1 Replies

DataSource Controls :: Much Slower Linq Query Than Optimised Sql ?

Feb 19, 2010

Slow query.Much slower linq query than optimised sql ?

View 1 Replies

DataSource Controls :: Check Query Return Value Or Not In LINQ

Jun 2, 2010

i have a Linq query that check something in database

after that i want to check if record find in database or not

dim re = From r in db.mytable _
where r.ID = _ID
Select r

how can i check the re return somthing or empty

View 1 Replies

DataSource Controls :: Cannot Get The Linq To SQl Query Return Type Working(C#)?

Apr 14, 2010

I am trying to fill a gridview with the data from Product table selecting few columns . I am using 3 - tier architecture and in DAL getproduct(userid) I am writing the query but cannot figure out exactly how to get that working .. here is piece of method I wrote

public List<Project> GetProjectList(int ownerId)

View 11 Replies

DataSource Controls :: LINQ To Entity Query - Getting Data From The RDBMS

Jan 1, 2010

if LINQ to Entity queries the EDMX class or its .CSDL or SSDL XML on its way to getting data from the RDBMS?

View 8 Replies

DataSource Controls :: Adding Attributes To A Linq Query Object?

Jan 11, 2010

Is it possible to add attributes in a linq query along with the other object data?

Here's what I have

[Code]....

But I'd like to add a custom attribute to each RadComboBoxItemData object in the query instead of having to do a foreach loop after the linq query to add the attributes on..

View 1 Replies

DataSource Controls :: LINQ To SQL Query / Like To Add An Asp:label To The Default.aspx?

Apr 23, 2010

I have a Dynamic Data Website that I created after watching the video tutorials on this website (I'm new to programming, but not computers).I have a SQL Table named 'Adult' that has a 'DOB' column. I would like to add an asp:label to the Default.aspx that does a LINQ to SQL query to determine if it's someones birthday today and if so display their name and age.

View 5 Replies

DataSource Controls :: Update Query Via LINQ Not Working As Expected?

Jan 6, 2010

I have a form that gets populated by LINQ and I want to be able to update the database using that same form. The form is populated by grabbing a querystring (for example, "edit=10") and searching the primary key for that record. So far so good. I have a button attached to the function below which is supposed to use LINQ to update the database with data from the form. I get no errors, but for some reason, it is only updating one field (Last_Updated) instead of all of them.

[Code]....

View 7 Replies







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