Database Utilities for C#

Lin100

Well-known member
Joined
Dec 12, 2022
Messages
69
Programming Experience
10+
The web site below has C# code that will allow a user to use the 8 lookup function quickly like Microsoft Access. I did download it.
I can see the code, but there is not much instruction how to use it.
Can anyone download it and show me how it work ?

//////////////////////////////////////////////////////////////////////////

Lookup Functions: Contains methods that query the database for a given value.
Namely the methods contained in this category are:
  • DLookup
  • DMax
  • DMin
  • DFirst
  • DLast
  • DSum
  • DAverage
  • DCount
///////////////////////////////////////////////////////////////////////////

 
My God, that is terrible. To be able to use those functions, you need:
An important note must also be made about the database design. All your tables should use a Guid as the primary key and they should also include an integer (SQL longinteger is preferable) field called AutoNumber which should number the records (identity should be set to Yes). Also, you will need to include a Guid field named User which will include the user ID of the user adding records to the database. I also use a RegDate field (of type SmallDateTime) which is filled by the SQL Server and adds the date when the record was inserted.

Why would you need two different ID key fields: a GUID and an ID numbers?

Why would you need to have the user and date last modified when all the functions above are read operations?

And furthermore, he parses a .config file himself instead of just using the configuration classes to get the connection string. I would be very leery of using this code.
 
Just use entity framework

DLookup:
C#:
  db.People.Where(p => p.Name == "John");

DMin:
C#:
  db.People.Min(p => p.Age);

And so on, all similarly easy one liners
 
Thank you Skydiver for your input. I thought it was difficult to use and you confirm it.
Thanks Cjard for the code. Can you elaborate the Dlookup code so I could test for myself.
 
Thanks Cjard for the code. Can you elaborate the Dlookup code so I could test for myself.
There isn't a lot to elaborate; that's pretty much how you would search a table. If you want to replicate DLookup exactly then you'd only select one field from the data..
 
Back
Top Bottom