Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic where condition
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Dynamic where condition
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:
01621606
Vues:
67
Hi everybody,

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.


Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform