>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.