This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi all, how can I use the OrderBy clause in C# 2.0? To better explain: I have an IList<Dividend>: private IList<Dividend> securitiesDividends; In the code I need to find all the records that satisfy a certain condition. The code to find that records and to make them ordered by the Id in VS 2008 should sound as:
afgeDividendi = s2005uow.Find< TblDividendi>(Entity.Attribute("DexAnn") == "N" && Entity.Attribute("DexDatapag") != null).OrderBy(p => p.Id).ToList(); It works fine. But how can I use the OrderBy clause (OrderBy(p => p.Id).) in VS 2005? Thanks in advance for your help CreF P.S. By the way, I'm using LS 2.2... ;-D |
|
|
Short answer: you can't. OrderBy is part of LINQ, which requires .NET 3.5 and C# 3.0. VS2005 doesn't support C# 3. However, you can do the ordering within the LightSpeed query, which will make it unnecessary to perform the ordering in C#. To do this, pass a Query object to the Find method, with the Query.Order property set appropriately: Query query = new Query(); Alternatively, if you really do need to sort an arbitrary list using C# instead of relying on the database, use List<T>.Sort. Note this is on the List<T> class not the IList<T> interface and that it sorts the list in place rather than returning a new sequence like OrderBy does. |
|
|
Hi Ivan, thanks for the quick answer. I just red your reply (please consider I live in Switzerland that is on the opposite side of the world). Unfortunately I have another problem regarding the same ft_asset table. The DB I'm working on is a legacy database so I can't change or add any data to the "core" tables. I can work only on a staging area and some built in procedures transfer data in the core. But I need to read the Asset basic data in order to let my colleagues to investigate on Assets static data. The proble is that if I do a Find using the UDVALOREN field everithing works fine. But in some cases this field (it represent the Telekurs Number, Telekurs is part of ANNA [Association of National Numbering Agencies] and is the swiss unique identifir of an asset like the ISIN number) is null. In that case the "Find" returns a massage that the entity is empty. Consequently I try to identify the asset using the UDWPK field that is the Custodian Bank identifier composed by the Telekurs number filled at left with 0 (zero) up to 10 chars. But in that case an exception is thrown: ORA-01460: unimplemented or unreasonable conversion requested I'm not able to understand why... When I use the query built sql executing it on Oracle using TOAD, it works and the item I'm searching for is loaded. The record exist in the table. Consider that in the procedure I'm looping through a list of items and I have to associate them to the correct ID of the ft_asset table. Please find here: a) the LS find Query I'm using >>
Query qrynvt = new Query(Entity.Attribute("Udwpk") == dividSS2005.DexNvt.Trim().TrimStart('0').ToString());
b) Oracle is 10g anf the table is in schema FIS; c) A security UDWPK on which the FIND fails is '0000808607'; I would like to send you the table script and the records at the moment in the ft_asset table, but I'm not able to find a way to attach the file. Can you help me in understanding why this error? Thanks in advance for your help CreF (formerly Francesco) ;-D |
|
|
You can attach files to a forum post via the Options tab (only one file per post). ORA-01460 is a bit of an enigmatic error. It usually seems to be related to extremely long strings (4000+ characters) though that seems a bit strange in this case given that the UDWPK value is a "normal" length. It may be related to the parameter type which is why it would not show up in Toad. (The SQL you see in the logger substitutes parameter values back in for parameters to make it more readable.) Try setting LightSpeedContext.VerboseLogging = true. This will cause LightSpeed to also print out the types of the command parameters. See what happens if you execute through Toad using parameters of those types rather than literals. Other thoughts: * Double-check that the value being passed to Oracle in the parameter is <4000 characters. Just in case. * Check if the UDWPK column is defined as a CLOB rather than a VARCHAR2. |
|