Wednesday, August 16, 2023

MCQs






What is a DbContext in Entity Framework?

a. An object that represents a database connection
b. A base class for all model classes in Entity Framework
c. An object that manages the entity objects and the underlying database connection
d. A class that represents a database table

Answer: c. An object that manages the entity objects and the underlying database connection

Explanation: DbContext is an object that manages the entity objects and the underlying database connection in Entity Framework. It is responsible for tracking changes to the entity objects and persisting these changes to the database.

Tuesday, August 8, 2023

Entity Framework interview questions

 
Entity Framework has the following advantages:

  • With its excellent prototypes, it is possible to write object-oriented programs.  
  • By allowing auto-migration, it is simple to create a database or modify it.   
  • It simplifies the developer's job by reducing the code length with the help of alternate commands.   
  • It reduces development time, and development cost, and provides auto-generated code.   
  • A unique syntax (LINQ / Yoda) is provided for all object queries, whether they are databases or not.  
  • It enables the mapping of multiple conceptual models to a single storage schema. 
  • Business objects can be mapped easily (with drag & drop tables).

C# Program to Reverse a String Using Recursion

 

C Program to Reverse a String Using 

Recursion


// C program to reverse a string
// using recursion
# include <stdio.h>
 
// Function to print reverse of
// the passed string
void reverse(char *str)
{
  if (*str)
  {
    reverse(str + 1);
    printf("%c", *str);
  }
}
 
// Driver code
int main()
{
  char a[] = "Geeks for Geeks";
  reverse(a);
  return 0;
}


C# Program to Remove All Duplicate Characters in a String

 

C# Program to Remove All Duplicate Characters in a String



// C# program to remove duplicate character
// from character array and print in sorted
// order
using System;
using System.Collections.Generic;
class GFG 
{
static String removeDuplicate(char []str, int n)
{
    // Used as index in the modified string
    int index = 0;
  
    // Traverse through all characters
    for (int i = 0; i < n; i++)
    {
  
        // Check if str[i] is present before it 
        int j;
        for (j = 0; j < i; j++) 
        {
            if (str[i] == str[j])
            {
                break;
            }
        }
  
        // If not present, then add it to
        // result.
        if (j == i) 
        {
            str[index++] = str[i];
        }
    }
    char [] ans = new char[index];
    Array.Copy(str, ans, index);
    return String.Join("", ans);
}
  
// Driver code
public static void Main(String[] args)
{
    char []str = "geeksforgeeks".ToCharArray();
    int n = str.Length;
    Console.WriteLine(removeDuplicate(str, n));
}
}
// C# program to remove duplicate character
// from character array and print in sorted
// order
using System;
using System.Collections.Generic;
  
  
public class GFG{
  
static char []removeDuplicate(char []str, int n)
{
      
    // Create a set using String characters
    // excluding '�'
    HashSet<char>s = new HashSet<char>(n - 1);
    foreach(char x in str)
        s.Add(x);
          
    char[] st = new char[s.Count];
      
    // Print content of the set
    int i = 0;
    foreach(char x in s)
       st[i++] = x;
    
    return st;
}
  
// Driver code
public static void Main(String[] args)
{
   char []str= "geeksforgeeks".ToCharArray();
   int n = str.Length;
     
   Console.Write(removeDuplicate(str, n));
}
  
// This code contrib
uted by



NET Core Code Security, Authorization/Authentication, and code architecture

Complex NET Core interview questions (Code Security, Authorization/Authentication, and code architecture)  _________________________________...