-1

Actually I am using C# entity. I have added new Entity class for newly added table in .edmx file manually.The issue is can get all rows with all column from DB. But cann't select specific column using select new {}. actual error is Error CS0012 The type 'DbDataRecord' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxx'.

This query working fine and it brings all the rows from DB

var listQuery = objReport.Batter_YTD_Tbl.ToList();

When i try like below throwing error

(from YTD_Tbl in objReport.Batter_YTD_Tbl 
 select new { test = YTD_Tbl.AB})
.ToList();

The error is

Error CS0012 The type 'DbDataRecord' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxx'. 805AdminPortal.Reports D:\xampp\htdocs\805\AdminSite-Starting-Code\805AdminPortal.Reports\Reports\PregameReport.cs 50 Active

DavidG
  • 113,891
  • 12
  • 217
  • 223
  • 1
    I haven't use C# that much but to me this looks like it wants you to "import"/"use" the `System.Data` namespace – Vivick Jun 01 '18 at 09:36
  • But i exisiting table seem getting no error. Only having issue for waht i added – user8646340 Jun 01 '18 at 09:40
  • Is the EDMX part in the same project (assembly)? You added a a statement that activates a few more parts of Linq, I would just o with the advice from the error, add System.Data or find out what package you are missing – bommelding Jun 01 '18 at 09:43
  • @davidg - the question here is for a large part _why_ that assembly is needed for 1 query and not for the other. And it isn't a done deal yet that this is about a missing dll. Edmax is more complicated. – bommelding Jun 01 '18 at 09:45
  • @user8646340 - when adding the assy doesn't work, do come back and [edit] this question or open another. – bommelding Jun 01 '18 at 09:46
  • @bommelding Yes, looks like a pretty good duplicate to me! – DavidG Jun 01 '18 at 09:47

1 Answers1

0

looks like you need to add reference to System.Data , so do as below

Right click Reference and select Add Reference... In the window that comes up, select the assembly System.Data

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263