VS 2013 - Linq Order By Not Working

Jan 13, 2015

i use below code

HTML Code:
(From r In tblRoles
Join m In module_master On m.module_id Equals r.module_id
Where Not r.role_name.ToUpper.Contains("OWNER") And Not r.role_name.ToUpper.Contains("CLIENT")
Order By m.module_name, r.role_name
Select r.module_id, m.module_name ,r.role_name
).Distinct
and output is

[code]....

but when i remove distinct then order by works properly..???

View 4 Replies


Similar Messages:

C# - Order By Descending Is Not Working On LINQ To Entity?

Apr 15, 2010

Order by descending is not working on LINQ to Entity In the following Query In place of ascending If I keep descending it is not working.

[code]....

View 1 Replies

DataSource Controls :: Compile In Order To Get The System.Linq.Dynamic Namespace / Dynamic Linq Error

Apr 20, 2010

I've added the Dynamic.cs file to my project and have set it's Build Action = Compile in order to get the System.Linq.Dynamic namespace.

However, when I try to use any of the new code I am getting an ambiguous call error; see below.

[Code]....

View 2 Replies

ADO.NET :: How To Order An Arraylist With Linq

Sep 9, 2010

Is there a way I can sort this query result in Linq? I'd like to sort in descending order by the .Count parameter:

[Code]....

View 2 Replies

ADO.NET :: How To Use LINQ In Order To Filter Out Only Objects

Nov 24, 2010

I have a collection of objects that I want to use LINQ in order to filter out only objects that have properties that meet a certain criteria. I am not big on LINQ so I am not sure how to do this.

I create a basic LINQ statement and get the records this way

Dim lr As IEnumerable(Of LogRecord) = From rr In _logRecords where rr.username="something"

but I only want to add that where condition if someone actually filled in a textbox.

I have other conditions to do the same thing with.

View 5 Replies

ADO.NET :: Linq - Order By Column That Contains Query?

Aug 19, 2010

I got a sql table and is trying to sort the data by the column that contains the data entered in a search form.

My code is below:

[Code]....

View 2 Replies

ADO.NET :: How To Use Order By On The Result Of A LinQ To SQL Query

Dec 8, 2010

How can I use Order by on the result of a LinQ to SQL query ?

I have the following Situation:

Dim ret As New Object

ret = From status In tableStatus _
Select status.STATUS_ID, _
Text = Function_GetText(status.TEXT_ID)

Now I have to order this result on the field Text, has anyone an idea? (I can't use in my case Orde by Function_GetText(status.TEXT_ID))

View 3 Replies

ADO.NET :: Order By A Field In Dictionary Using Linq Expression?

Aug 16, 2010

I have an Entity class which has a Dictionary of fields called Data. Now I want to sort Entities by a field in Data. I was able to verify the Linq expression for using fields in a dictionary as e.Data["UserId"] as this seemed to work perfectly when I used LINQ to Objects. e.g. Entities.OrderBy(e => e.Data["UserId"])

However this same expression does not generate the correct NHibernate criteria and errors out finally with a NullReferenceException for propertyName at Hibernate.Loader.Criteria.CriteriaQueryTranslator.GetEntityName(ICriteria subcriteria, String propertyName)in CriteriaQueryTranslator.cs: line 541.

On debugging through NHibernate code, I figured that NHibernate.Linq.Visitors.MemberNameVisitor.GetMemberName(ICriteria rootCriteria, Expression expr) returns a null string in place of the field name after visiting expr using its visitor. This seems to be the cause of grief. I am using an older version of NHibernate (2.1). Are there any limitations in the NHibernate Linq visitor I should be aware of?

View 1 Replies

DataSource Controls :: Order By Count And Group By In LINQ?

Mar 14, 2010

How do I translate the following query into LINQ to SQL?

[Code]....

View 1 Replies

C# - Order Datatable By Relevance Using Linq By Column Values Which Are Comma Sperated?

Aug 31, 2010

I have a Datatable that contains a column called Tags, Tags can have values such as

row[0] = Tag1
row[1] = Tag1, Tag2
row[2] = Tag2, Tag3
row[3] = Tag1, Tag2, Tag3
row[4] = Tag4, Tag6

and are seperated by comma's etc..

I have the value of Tags for the current document and have run a query to select all other documents that have either of the Tags in there row. for example lets say the current document Tags are (Tag1, Tag2, Tag3)

so from the example rows above all the rows above are returned apart from row[4] Here is the bit i'm lost with, i now want to sort the datatable by how many tags are matched with the current document. so for the example i've talked about so far they should be ordered

row[3] = Tag1, Tag2, Tag3
row[1] = Tag1, Tag2
row[2] = Tag2, Tag3
row[0] = Tag1


Not used linq before but was told it could do this. so far i have

var query = from c in dt.AsEnumerable()
orderby c.Field<string>("Tags").CompareTo(dr["Tags"]) ascending
select c;

View 3 Replies

MVC :: Create A DraftResult Class In Order To Show Data That Resides In Two Different Tables Using Linq

Aug 9, 2010

The problem is I had to create a draftResult class in order to show data that resides in two different tables using linq which means if i want to add or remove a column i will need to do so in the draftresult and in my linq. Here's what my setup looks like: I have two tables (draft, lookUpStatus)

draft table columns
idname,status id
lookupStatus
idtitle
public class draftResult {
public string draftName {get; set;}
public string status {get; set;}
}

I want to list the draft name and the status title in a table view. In order to do this, I wrote the following linq in a method in my sqlRepository class and return it to a IQueryable<draftResult>. My controller instanstiates the sqlRepository object and invokes GetDraftListing().

public class sqlRepository {
private Table<Draft> _draft;
private Table<LookUpStatus> _lookupubStatus;
public IQueryable<draftResult> GetDrafLtisting() {
return (from draft in _draft
join status in _lookuptatus
on draft.StatusID equals status.ID
select new draftResult
{
draftName = draft.name,
status = status.Title
});
}
}

The above process works but does not seem as flexible and i'm trying to get a better understanding of MVC and LINQ.

View 8 Replies

SQL Server :: ORDER BY CASE Is Not Working

Jan 19, 2011

I am having trouble with my ORDY By Case Statement. It doesn't seem to be ording correctly. To see it in action, please go to [URL] and click on "latin" and it should change the sort order and when you click back on "common" it should change it back but it doesn't. Here's my code:

[Code]....

View 17 Replies

DataSource Controls :: What's Faster Working With DataSet OR Working With Collections (LINQ To Entities)

May 21, 2010

I mean, what is the faster way to get as fast as I can more than one table with stored procedure? Is there any study what is faster and why? There is a big problem getting more than one table at once with Entities, so the only way is DataSet. But I was told DataSet work very slow. Is that true?

View 2 Replies

ASP - Tab Order Not Working After Ajax Postback - Goes To Browser Url

Sep 30, 2010

I have used Update Panels in my ASP.net webpage. I have a modal popup. But the tab index is set to -1 for all the parent page controls once the modal popup comes in picture. Does anybody has resolution for this. I tried again reseting the tab index through javascript......But its not working(may be DOM is not getting refreshed)

View 1 Replies

Web Forms :: Rearranging Texbox Order - Maintain Order In Insert / Update Cases

Jan 23, 2010

I have 5 hard corded texboxes in a page in a sequence with sequence Number . Now i want to add re-order /re-arraning functionaly .. but i can't use ajax reorder list because i have 5 hard corded texbox. how can i maintain the order in Insert/Update cases. And also suggest me control that i can use, another than ajax re-order list. coz i not using any list items i have hard corded items on the page.

View 1 Replies

JQuery :: Reorder List - Change Order Of Divs And Upload New Order To Database

Feb 7, 2011

The AjaxToolkit has a ReorderList. I'm searching for a jQuery solution that does the same and found this page. I would like to change the order of divs (vertically) and upload the new order to the database (ajax).

View 2 Replies

C# - SQL Statement Transformed TO LINQ - How To Translate This Statement To A Working Linq

Mar 5, 2010

I am having trouble with this I have 3 Data tables i use over and over again which are cached I would like to write a LINQ statement which would do the following is this possible?

T-SQL VERSION:

SELECT P.[CID],P.[AID]
,B.[AID], B.[Data], B.[Status], B.[Language]
FROM MY_TABLE_1 P
JOIN
(
SELECT A.[AID], A.[Data], A.[Status], A.[Language] FROM MY_TABLE_2 A
UNION ALL
SELECT B.[AID], B.[Data], B.[Status], B.[Language] FROM MY_TABLE_3 B
) B on P.[AID] = B.[AID]
WHERE B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1 AND B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1

Then i would like it to create a result set of the following

Results:
|CID|AID|DATA|STATUS|LANGUAGE

View 3 Replies

Forms Data Controls :: Datacontrol For Order And Order Detail - How To Fetch Record Based On Paging

Oct 22, 2010

I have two table Order and Order Detail.

What i need is i need to bind last 10 Order in Gridview/details view with paging, and the same order detail also fetch from database and shown in another gridview.. if user click any oderNo in first Gridview/DetailView then i need to show Respective order detail in anther gridview..

without postback coz we already fetch 10 order with orderdetails from the database..and if user click next 10 orderNo using paging then again we need to load 10 orderNo with respective orderdeatils from database like this going on....as well as let me know how to take print of particular oder and order detail....?

View 7 Replies

Access :: UpdateParameters - Form Order - UpdateCommand Order?

Apr 24, 2010

From my testing, it appears that the order of parameters for the UpdateParameters must match both the order of the bound fields on the form (asp:Formview), and the order of the parameters in the UpdateCommand. Is that correct? If so, why do the parameters have names if all that matters is the order? I tried both asp:ControlParameter and asp:Parameter. Maybe the more relevant question is why aren't the names used instead of the order, particularly for the form order?

So, given I display the Identity field (CID), and need that for the update, I cannot get the update to work without including it in the UpdateCommand. Of course, since it is an autonumber field in Access, I cannot actually set it. So, I had to add another field to the db (lngUpdateCID) that I could set. That can't be how it has to be done, but I could not figure out another way to do this.

The relevant code is below:

[Code]....

View 23 Replies

Data Controls :: Gridview Paging Not Working In Data Arranged In Descending Order

Oct 16, 2012

I am using dropdownlist to select whether the gridview should be filled by data arranged in ascending order or descending order with Gridview Paging. The problem i am encountering is that when i fill the data in ascending order it works fine but when i arrange the data in descending order the first page loads fine but the other pages are not filled properly in paging.

View 1 Replies

.net - LINQ-Query Is Not Working?

Dec 13, 2010

Table User (UserID, Username)
Table Admin (AdminID, Username)
Table PM (PMID, SenderID, Sendertype, RecipientID, RecipientType)
Get all Information from PM
if SenderType == 'A' join SenderID to Admin-Table, get Username
if SenderType == 'U' join SenderID to User-Table, get Username
if RecipientType == 'A' join RecipientID to Admin-Table, get Username
if RecipientType == 'U' join RecipientID to User-Table, Get Username

someone have an Idea how to solve in 1 query?

View 3 Replies

Selected Value From DropDownList In Linq Is Not Working?

Jan 7, 2011

I have this code frontline (default.aspx)

[Code]....

And then i have a codeBehind i get an Error 1 'SortBy' is not declared. It may be inaccessible due to its protection level. and i cant see why!??My codebehind (default.aspx.vb) is

[Code]....

View 1 Replies

ADO.NET :: Contains() Method Not Working In Linq To Entities

Mar 8, 2011

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]

View 2 Replies

Serialize Linq Objects Not Working?

Apr 14, 2010

Using the following code:

Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c
Dim dcs As New DataContractSerializer(GetType(Customer))
Dim sb As StringBuilder = New StringBuilder
Dim writer As XmlWriter = XmlWriter.Create(sb)
dcs.WriteObject(writer, customer)
Dim xml As String = sb.ToString
Response.Write(xml)
End Sub

I am attempting to serialize my linq collection of customers. But it keeps throwing

Type 'System.Data.Linq.DataQuery`1[MyDB.Customer]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types.

My issue is that I have already marked the dbml Serialization Mode to UniDirectional and when I check the dbml codebehind all of the DataContract()> and DataMember()> elements are there.

I am not sure how to proceed. I have tried adding various dataloadoptions and setting deferredloading to false, but no luck.

View 2 Replies

C# - Join Is Not Working In LINQ Statement?

Mar 23, 2011

I am new to LINQ. I have a GridView which I am populating using LINQ. My LINQ statement is taking query string from previous page. The query string is in string format. Here is the code:

protected void Page_Load(object sender, EventArgs e)
{
string getEntity = Request.QueryString["EntityID"];

[code]...

View 3 Replies







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