Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic where condition
Message
De
30/06/2015 14:26:19
 
 
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
Application:
Web
Divers
Thread ID:
01621606
Message ID:
01621607
Vues:
38
>I am contemplating on a better way to implement the following.
>
>I have a wide table called max4sale which has type and department, category, item, lesson_cat, etc. columns. They are populated depending on the type. The structure of this table is pre-defined and we're not going to change it (just to avoid discussion about the table's design).
>
>In VFP I have the following code to check for possible conflicts when a row is inserted / updated in that table:
>
>
>wait window "Checking for time conflicts..." nowait noclear
>		text TO lcSQL TEXTMERGE noshow
>        select COUNT(ID) as conflicts
>        from dbo.max4sale where type = <<VFP2SQL(type)>>
>        and <<thisform.cWhere>>
>        AND Start_Time >= <<VFP2SQL(Start_Time)>>
>	    and Start_time <= <<VFP2SQL(End_Time)>>
>	    and ID <> <<VFP2SQL(Id)>>
>		ENDTEXT
>
>		*    _cliptext = m.lcSQL
>
>		mysqlexec(m.lcSQL, 'csrTemp', program())
>
>
>where thisform.cWhere was constructed in form's Init depending on the type.
>
>So, I'm thinking of somehow re-producing that either as LINQ query or as a stored procedure where I'd pass many parameters and use dynamic SQL to construct the query.
>
>Assuming I am going to try the first approach of the LINQ query, how can I do that type based condition dynamically, e.g.
>
>if type = 1, then I want to check department column, for example. If type = 2, then department and category, etc.

What is not working exactly? In your .NET code, when you build your select command, you can decide to build it upcon any condition you want.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform