Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transformations on returned data set
Message
 
 
À
09/05/2013 16:55:52
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01573095
Message ID:
01573306
Vues:
31
>Naomi,
>
>you already have some answers on how to do it client side in dotnet. But as you probably have some SQL code doing it, why not keep munging in SQL and do the stuff server side ? IMO Dotnet munging sucks...
>

The reason is that I have a stored procedure that returns my result before this extra massaging. The stored procedure actually returns few extra columns I do not need for this particular method.

So, I want to transform on the client, besides, it is a well known fact that extra formatting should be done on the client (.NET application) in this case rather than on the server.

So, this is what I have so far
var results = from r in ds.Tables[0].AsEnumerable()
                                select new {resource1 = r.Field<String>("resource1"),
                                booking_id = r.Field<Int64>("booking_id"),
                                start_time = r.Field<DateTime>("start_time"),
                                end_time = r.Field<DateTime>("end_time"),
                                flex_tspan = r.Field<Boolean>("flex_tspan"),
                                layer = r.Field<Int16>("layer"),
                                backcolor = r.Field<Int32>("backcolor"),
                                forecolor = r.Field<Int32>("forecolor"),
                                clip_sp = r.Field<String>("clip_sp"),
                                clip_loc = r.Field<Int16>("clip_loc"),
                                display_msg = "".PadRight((r.Field<Boolean>("locked"))?2:0) + 
                                (String.IsNullOrEmpty(r.Field<String>("department") + r.Field<String>("category") + 
                                r.Field<String>("item"))?("**"+r.Field<String>("lsndescrip").Trim() + "**").R

                                };
(not finished since I now need replicate function in C# - I found this http://stackoverflow.com/questions/3754582/is-there-an-easy-way-to-return-a-string-repeated-x-number-of-times and wondering if I should go with String.Concat or create an extension - (if we don't have it already).
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform