Retrieve query metadata in Postgres - c#

With a C# .net application connecting to postgres using npgsql, how do I recover the just the metadata of a sql query? Is their any equivalent to the Transact SQL option FMTONLY, where the request returns no rows, and makes no changes, but populates the column meta-data with the schema information - column names and data types?

Related

Using Microsoft.Data.Analysis how can I fetch data from database to Dataframe?

I am trying to use Microsoft.Data.Analysis in .net6.
Is it possible to get data from database into Dataframe?

Getting a System.Byte[] from a SSIS package ADO.NET datasource

I'm using a SSIS package to retrieve Data from active directory and to make a few conversions and write it into a SQL Server destination table (via update ole db command).
Now I've run into the problem that one of the fields retrieved is of type System.Byte[] and it is the TYPE that is written into the field of the sql server database (thus the field UserSID gets the value "System.Byte[]" instead of the user SID itself. the userSID is a unicode varcahr with a max. length of 255).
ole db source sql command:
SELECT extensionAttribute2, mail, objectSID FROM 'LDAP://XXXXXXX' WHERE objectClass='User'
So my question here is: how can I get the value and not the type back from the source object?

Is there any way to create a DbCompiledModel without having EF load provider information from the database?

I'd like to construct an EF DbCompiledModel from a DbModelBuilder without actually connecting to a database. Is there any way to do this? It looks like I can build a model using a DbProviderInfo, but I don't know how to get a providerInvariantName & providerManifestToken.
The reason I would like to do this is that I want to leverage the EF to SQL compiler offline to generate some queries without having access to the database. I'm using EF 5.
For SqlServer the provider invariant name is "System.Data.SqlClient" and the provider manifest tokens are "2005" for SqlServer 2005, "2008" for SqlServer 2008. In EF6 there are also "2012" for SqlServer 2012 and "2012.Azure" for Azure.

Calling a Sybase SP, error "SP not found"

I am connecting to a Sybase 9 database to retrieve data. I can query the database without issue using ODBC connections but I am having an issue calling stored procedures. The procedure was written probably 6-7 years ago. This is what I have to execute the stored procedure.
OdbcCommand itemWeightAve = conn.CreateCommand();
itemWeightAve.CommandText = "ComputeLastCost";
itemWeightAve.CommandType = CommandType.StoredProcedure;
itemWeightAve.Parameters.AddWithValue("#OwnerId", "BananaHammock");//company number
itemWeightAve.Parameters.AddWithValue("#InventoryId", InventoryNumberHere);//inventory id from query results
itemWeightAve.Parameters.AddWithValue("#EndDate", EndDateHere);//end date from query results
OdbcDataReader itemAveReader = itemWeightAve.ExecuteReader();
I am not very familiar with Sybase or ODBC and the version these guys are using is extremely old and is no longer officially supported. Upgrading the Sybase database is out of the question. The error I get when attempting to execute this command is...
ERROR [42S02] [Sybase][ODBC Driver][Adaptive Server Anywhere]
Procedure 'ComputeLastCost' not found
I know that the procedure exists, it is typed correctly, and that the parameter names exist and are typed correctly. Does anyone have any tips/hints/suggestions for what I'm doing wrong here?
Turned the comment into an answer...
What is the default database of the login that you are using?
Is the stored procedure in the same database?
If not, you need to prefix your procedure name with the database name "sharedDB.ComputeLastCost".
You can check this by logging in with the same user/password through isql and try and exec it by hand. if you have to do a use database (ie. use database sharedDB) before you execute it, you need to put the db name in front.
You can also change your default database for the user. Either way should work.

Entity Framework and Encrypted Database

I have a column (salary) encrypted in database (MS SQL Server).
I am using the entity framework to display/edit the records from the front end. Any idea how to decrypt the column in the front end to show the salary value?
Thanks
If you are doing encryption on database level you must use database level for decryption - use ObjectContext.ExecuteStoreQuery<YourEntityType>(...) to load records from database - pass SQL command with correct decryption usage into that method.

Categories