Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate

Convert linq to sql query

Hi , I struggle to convert a query from linq to sql ,my query is: from box in _context.MailIteboxStore.Where(x => x.boxId == boxId) .Include(x => x.boxItem).ThenInclude(x => x.boxItemGen)...

View Article


The instance of entity type cannot be tracked because another instance with...

The instance of entity type 'Table' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity...

View Article


EF Core, first query is slow, how to generate a precompile view to improve...

Hi,I am working on webapi 3.1 with entityframework core 3.16. I got about 180 entity that is slow with the first query. I read that precompiled entityframework view can help improve performance. I...

View Article

Seeding users using UserManger and Identify role class thinks its a static class

I am trying to seed users and permissions but no matter what I do I get the following error.But when you look below at my code not one method is a static method so why on earth is visual studio...

View Article

Scaffold common base class for all entities

Creating ASP.NET 5 Core MVC application using Npgsql EF Core provider. Scaffold creates Poco classes like namespace MyDbContext { public partial class Customer { public Customer() { } public string Id...

View Article


Help with composing async Task .....

I must select distinct values from one column named YEAR from the database table.  I MUST use async Task<IEnumerable<variables>> for this code in my class library.I need help with the body...

View Article

Help retrieving columns from StoredProcedure using LINQ...

I need to retrieve data by using a stored Procedure using MVC LINQ.   I need to retrieve two fields from the table.My method is a public async Task IEnumerable and inside the body needs to return two...

View Article

Linq GroupBy and Sum - .First() could not be translated

My data is owner, location, date, charge, payment, the plan is to get a list of owners, each having a location, and the Sum OwnerTotal (charge - payamount)OwnerIdLocationChargePayAmount1Loc 110001Loc...

View Article


Editing SQL database items and Model Binding attributes?

Problem: I want to update an SQL database record and not create a new database entry.The ASP.Net Core MVC application I am working on involves inventory tracking.  Data are stored in an MS SQL server...

View Article


EF Core 5.0.X Model Customizations - database first

I am modernizing a 4.X aspnet app to Blazor  Server/Wasm.In the original app I was using EF 6.4.X and a whole bunch of model customizations. Been looking for how I can stil use these but all I find is...

View Article

Walking into an antipattern? Fetching data multiple FKs many layers deep ...

Using SQL and EF Core, I need to efficiently fetch data scattered across many tables.There are ~50 tables, with many tables having multiple FK relationships, and the layers of FK relationships run up...

View Article

executeScalar method is giving error

Hi All,public string execCount(string query)        {            string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;            using (SqlConnection con = new...

View Article

listbox does not show the data

   public DataTable getCourses()        {            string CS = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;            using (SqlConnection con = new SqlConnection(CS))...

View Article


Sum and Case to linq

Need help to convert sql to linq in c#SELECT    SUM(CASE WHEN Evaluation.StatusId = 3 THEN 1 END)AS EvalutionOK,        SUM(CASE WHEN Evaluation.StatusId = 4 THEN 1 END) AS EvalutionTodo,...

View Article

How to use Clause "IN"

Hi All,How can I passed array companies id into the .Where highlight orange query below:-var companies = companies.Where(c=>!c.Id.Equals(0)).Select(c => c.Id).Distinct().ToList();...

View Article


LINQ and Entity Framework errors

I have two tables in SQL database:Challenger (ChallengerID, FirstName, LastName, Email) Rank (RankID, ChallengerID, Best, DateAcheieved) and using entity framework to access data. When I am trying to...

View Article

Is there a way to get a link query to return a row from a table?

So I am trying to access a database table that has a field that I need to match and if there is a match I need to select data out a field in  that table. I have tried and few things and I am coming up...

View Article


Can't migrate Entity Framework

HiI run this command on package manager console :pm>add-migration FirstAppDemobut keeping get this image:The project first app demo failed to build.What should I do?please inform.regardsSaeed

View Article

Number of rows returned by a DataReader

Hi, Is there any way to know how many rows the data reader returns after executing a SQL statement? For now, I am doing the follwing:if datareader.hasrows then while datareader.read count += 1 end...

View Article

issues in defining relationship between entities in EntityFramework core code...

Hi Aall,I am completely new to Entity framework, working on sample app.Following the .entity framework CodeFirst approach for  asp.net  core web apiwe created two entities public class Account { public...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>