![]() |
VOOZH | about |
This article illustrates using LINQ to access tables within the AlloyDB via the CData ADO.NET Data Provider for AlloyDB. To achieve this, we will use LINQ to Entity Framework, which facilitates the generation of connections and can be seamlessly employed with any CData ADO.NET Data Providers to access data through LINQ.
See the help documentation for a guide to setting up an EF 6 project to use the provider.
Enter your data source connection information.
The following connection properties are usually required in order to connect to AlloyDB.
You can also optionally set the following:
Standard authentication (using the user/password combination supplied earlier) is the default form of authentication.
No further action is required to leverage Standard Authentication to connect.
There are additional methods of authentication available which must be enabled in the pg_hba.conf file on the AlloyDB server.
Find instructions about authentication setup on the AlloyDB Server here.
This authentication method must be enabled by setting the auth-method in the pg_hba.conf file to md5.
This authentication method must be enabled by setting the auth-method in the pg_hba.conf file to scram-sha-256.
The authentication with Kerberos is initiated by AlloyDB Server when the ∏ is trying to connect to it. You should set up Kerberos on the AlloyDB Server to activate this authentication method. Once you have Kerberos authentication set up on the AlloyDB Server, see the Kerberos section of the help documentation for details on how to authenticate with Kerberos.
Below is a typical connection string:
User=alloydb;Password=admin;Database=alloydb;Server=127.0.0.1;Port=5432
Using the entity you created, you can now perform select , update, delete, and insert commands. For example:
AlloyDBEntities context = new AlloyDBEntities();
var ordersQuery = from orders in context.Orders
select orders;
foreach (var result in ordersQuery) {
Console.WriteLine("{0} {1} ", result.Id, result.ShipName);
}
See "LINQ and Entity Framework" chapter in the help documentation for example queries of the supported LINQ.
Download a free trial of the AlloyDB Data Provider to get started:
Download NowLearn more:
👁 AlloyDB IconRapidly create and deploy powerful .NET applications that integrate with AlloyDB.