Print Page | Close Window

how can I sort the entities from 'B' to 'D'?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1372
Printed Date: 16-Apr-2024 at 3:22am


Topic: how can I sort the entities from 'B' to 'D'?
Posted By: monkeyking
Subject: how can I sort the entities from 'B' to 'D'?
Date Posted: 10-Jul-2009 at 11:26pm
I want to make query to find out all 'Debtor' entities which the property of 'L_NAME' from 'B' to 'D', how can I do it?

sth like that,

var query = AdditionalFunctions.manager.Debtors.Where(o => o.L_NAME >= 'B' && o.L_NAME <= 'D');

but actually this line of code doesn't work, if you get my mean, please let me know a correct way to achieve this

Regards
John



Replies:
Posted By: GregD
Date Posted: 16-Jul-2009 at 11:55am
Two ways:
 
     manager.Debtors.Where(o => o.L_NAME.StartsWith("B") || o.L_NAME.StartsWith(C") || o.L_NAME.StartsWith("D") )
 
or more succinctly (better for a large set):
 
     manager.Debtors.Where(o => "BCD".Contains(o.L_NAME.Substring(0, 1)))



Print Page | Close Window