Retrieve data from two tables in asp.net mvc using ADO.Net Entity Framework -
Please read my question carefully and answer me.
I have two tables in table 1 and table 2. In Table 1, I call the address ID (primary key), address ID (the primary key), the address ID (the foregin key), the last name in the address ID (primary key), address1, address2, city
table 2 As are the columns, the first name.
Using the joining operation, I can get data from both tables.
I have created a model in my MVC application. I can see both tables in the unit editor.
In my solution Explorer's ViewData folder, I have created two classes as ContactViewData.cs and SLXRepository.cs.
In CSV in ContactViewData, I have the following code
Public IEnumerable & lt; Contacts & gt; Contact {received; Set; }
In SLXRepository.cs, I have the following code
public IEnumerable & lt; Contacts & gt; GetContacts () {contact with var = (c.CONTACT in reference) at c.ADDRESSID one. To join, a.ADDRESSID equals new {a.ADDRESS1, a.ADDRESS2, a.CITY, c.FIRSTNAME, c.LASTNAME}); Return contact; }
I am getting the error in the return type
type "System.Linq.IQueryable" AnonymousType # 1 & gt; For 'System.Collections.Generic.IEnumerable & lt; SiennaSLX.Models.CONTACT & gt; A clear conversion exists (are not you leaving an artist?)
In Linq2Sql, your special query will return an IQueryable object
You can either change the return type of your method to IQueryable
Public IQueryable & lt; Contacts & gt; Contact {received; Set; } Public IQueryable & lt; Contacts & gt; GetContacts () {contact with var = (c.CONTACT in reference) at c.ADDRESSID one. To join, a.ADDRESSID equals new {a.ADDRESS1, a.ADDRESS2, a.CITY, c.FIRSTNAME, c.LASTNAME}); Return contact; }
Or you enter your return value with the ASENemable () function:
Public INMMerable & lt; CONTACT & gt; GetContacts () {contact with var = (c.CONTACT in reference) at c.ADDRESSID one. To join, a.ADDRESSID equals new {a.ADDRESS1, a.ADDRESS2, a.CITY, c.FIRSTNAME, c.LASTNAME}); Return contact As number (); }
Comments
Post a Comment