-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
I want abilty to query 2 tables like sql join, Those2 tables wont have any relationshp in the table. I have generated models cs files and dbcontext.cs file using EF command automatically.
SELECT C.CCode, C.CName, P.PCode, P.PName
FROM Client C
INNER JOIN Product P ON C.MCode = P.MCode AND C.CCode = P.CCode....
I have this code in startup.cs
public void ConfigureServices(IServiceCollection services)
{
try
{
// Register IHttpContextAccessor
services.AddHttpContextAccessor();
// Register DBContext with IHttpContextAccessor
services.AddDbContext<DBContext>((serviceProvider, options) =>
{
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
var connection = new SqlConnection(GetConnectionString(httpContextAccessor));
// var creds = new Azure.Identity.DefaultAzureCredential();
// var token = creds.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://database.windows.net/.default" }));
// connection.AccessToken = token.Token;
options.UseSqlServer(connection);
});
int DefaultPageSize = Configuration.GetValue<int>("DefaultPageSize");
int MaxPages = Configuration.GetValue<int>("MaxPages");
services.AddGraphQLSchema<DBContext>(provider =>
{
provider.OnFieldCreated = (field) =>
{
if (field.ReturnType.IsList && field.ReturnType.SchemaType.GqlType == GqlTypes.QueryObject && !field.FromType.IsInterface)
{
field.UseFilter().UseSort().UseOffsetPaging(defaultPageSize: DefaultPageSize, maxPageSize: MaxPages);
}
};
});...
..............
.........
}.....
how and where I make these 2 tables related? what files would require changes? Client.cs, product.cs or dbcontext.cs or startup.cs?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels