Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all 1698 articles
Browse latest View live

LINQ syntax when using JOIN

$
0
0

I'm coding a Multi-Search module that uses the following approach.
The query builds according to dropdown selections and associated checkboxes.

My question is how to make the JOIN query part compatible with the style of the more straightforward queries?
************************************
 Public query(5) As String
.
.
        Dim db As New myDataContext
        Dim query As IQueryable(Of MainTable) = db.MainTables
.
.
        If CheckBox1.Checked Then
            query = query.Where(Function(u As MainTable) u.aaaID = dropdown_aaa.SelectedValue)
        End If

        If CheckBox2.Checked Then
            query = query.Where(Function(u As MainTable) u.bbbID = dropdown_bbb.SelectedValue)
        End If

    If CheckBox3.Checked Then
      ' how to write this following bit in the same or compatible style as the others ????

        query = From a In db.MainTables Join b In db.secondaryTable _
                    On a.ID Equals b.ID _
                    Where b.cccID = dropdown_ccc.SelectedValue
    End If
.
.
        result = query.Select(Function(u As MainTable) New With {u.ID, u.Surname, u.Town})
.

.
        gv.DataSource = query
        gv.DataBind()

Sorry about the complexity of my question but thanks in anticipation.


LINQ - Cannot cast DBNull.Value to type 'System.Double'. Please use a nullable type.

$
0
0

Hi,

I am getting Following Error.

Error : Cannot cast DBNull.Value to type 'System.Double'. Please use a nullable type.

double Range = 30.0;
string Studno = "A3";
string Result1 = null;
double Result2 = 0;


DataTable dt = new DataTable();
dt.Columns.AddRange(new[] { new DataColumn("StudentNo"),new DataColumn("FROM"),new DataColumn("TO"),new DataColumn("EQU"),
new DataColumn("VALUES") });
dt.Rows.Add("A1", "10", "10", "A+B", "100");
dt.Rows.Add("A2", "20", "20", "C+D", "300");
dt.Rows.Add("A3", "30", "30", "E+F", null);
dt.Rows.Add("A4", "40", "40", "G+H", null);
dt.Rows.Add("A5", "50", "50", null, "400");
dt.Rows.Add("A6", "60", "60", null, "500");

var QryVERTDIS = (from r in dt.AsEnumerable()
let FrS = Convert.ToDouble( r.Field<string>("FROM"))
let ToS = Convert.ToDouble(r.Field<string>("To"))
where
!string.IsNullOrWhiteSpace(r.Field<string>("StudentNo")) && r.Field<String>("StudentNo") == Studno &&
Range <= FrS && Range >= ToS
select new
{

}).Count();

if (QryVERTDIS > 0)
{

var QryIn2 = (from r in dt.AsEnumerable()
let FrS = Convert.ToDouble(r.Field<string>("FROM"))
let ToS = Convert.ToDouble(r.Field<string>("To"))
where
!string.IsNullOrWhiteSpace(r.Field<string>("StudentNo")) && r.Field<String>("StudentNo") == Studno &&
Range <= FrS && Range >= ToS

select new
{
Result1 = r.Field<string>("EQU"),
Result2 = r.Field<double>("VALUES"), // Error
}).Distinct();

foreach (var n1 in QryIn2)
{
Result1 = n1.Result1;
Result2 = n1.Result2;
}

}

What is the problem in the code...?

Pass null values to oracle parameter in C#

$
0
0

how to pass null values to oracle parameter in c# for different types ( int, date, string )

this is my code sample

  OracleParameter ParamCompID_obj = command.Parameters.Add("PI_COMPID", OracleDbType.Int32);
                                        ParamCompID_obj.Direction = ParameterDirection.Input;
                                        ParamCompID_obj.Value = obj.COMP_ID;

                                        OracleParameter ParamOBJECTIVEID = command.Parameters.Add("PI_OBJECTIVEID", OracleDbType.Int16);
                                        ParamOBJECTIVEID.Direction = ParameterDirection.Input;
                                        ParamOBJECTIVEID.Value = obj.OBJECTIVEID;

                                        OracleParameter ParamCATEGID = command.Parameters.Add("PI_CATEGID", OracleDbType.Int16);
                                        ParamCATEGID.Direction = ParameterDirection.Input;
                                        ParamCATEGID.Value = obj.CATEGID;

                                        OracleParameter ParamENTDATE = command.Parameters.Add("PI_ENTDATE", OracleDbType.Date);
                                        ParamENTDATE.Direction = ParameterDirection.Input;
                                        ParamENTDATE.Value = obj.ENTDATE;


 

Why does Remove() not delete objects from the database?

$
0
0

Hello,

In trying to figure out how to delete entities from the database in my MVC application, almost ever hit in google tells me that I need to use Remove(). As in:

ReportComment comment = report.ReportComments.LastOrDefault();
report.ReportComments.Remove(comment);

This is not true. This only orphans the entity. In the case of my ReportComment, it attempts to set the foreign key that points to the Report of which it is a child to null, and this causes the application to crash because the foreign key is set to be non-null. They way I had to solve this was as follow:

First create GetContext in my service:

public IRiskAliveContext GetContext()
{
return _context;
}

Then I call this function in my controller:

IRiskAliveContext context = _projectService.GetContext();

Then I use the context to call Entry() and then set the state of the Entry to Deleted:

ReportComment comment = report.ReportComments.LastOrDefault();
report.ReportComments.Remove(comment);
context.Entry(comment).State = EntityState.Deleted;

Why do I need to do this? Why does Remove() not work like google says?

EDMX Linq Query returning only 1st item in Cursor written in Stored Procedure in SQL

$
0
0

Hi,

I am having a Cursor in Sql within a Stored Procedure and when i use this in an EDMX Linq Query getting only 1st record with in Stored Procedure. what needs to do to get all the items in select statement within Cursor of SP in SQL>

Few question about entity-framework core-2

$
0
0

i read this page https://weblogs.asp.net/ricardoperes/what-s-new-and-changed-in-entity-framework-core-2

but few things is not clear to me so i will ask those area point wise.

1) what is the meaning of OwnsOne

modelBuilder
.Entity<Customer>()
.OwnsOne(c => c.PersonalAddress);

2) You can also put the content for these properties in another table, and you do it like this:

what they try to do with below code ? personal address is table name or column name?

are they try to map personal address to different table ?

modelBuilder
  .Entity<Customer>()
  .OwnsOne(c => c.PersonalAddress)
  .ToTable(“CustomerAddress”);

3) You can now have different classes that point to the same physical table, Entity Framework Core will not complain

need a example of Entity Framework Core which show how to map multiple classes to same physical table ?

4) Entity State Listener

what is GetService() function. is it buit-in or user define.

var events = ctx.GetService<ILocalViewListener>();
events.RegisterView((entry, state) =>
{
  //entry contains the entity and state its current state
});

need a small but full code for Entity State Listener in .net core

5) what is Pluralization and what it does and when to use it.

below code is not clear that what it is doing? so please help me to understand below code.

publicclass CustomPluralizerDesignTimeServices : IDesignTimeServices
{
publicvoid ConfigureDesignTimeServices(IServiceCollection services)
{
services.AddSingleton<IPluralizer, CustomPluralizer>();
}
}

publicclass CustomPluralizer : IPluralizer
{
publicstring Pluralize(string name)
{
return ...;
}

publicstring Singularize(string name)
{
return ...;
}
}

6) what is Global Filters ?

i use filter in mvc but what filter does in EF?

modelBuilder
  .Entity<Post>()
  .HasQueryFilter(p => !p.IsDeleted);


Or, for a multi-tenant:

modelBuilder
  .Entity<Blog>()
  .HasQueryFilter(p => p.TenantId == this.TenantId);

in this case with model builder we attach a filter that !p.IsDeleted does it means it ignore p.IsDeleted ?

if we set this filter with model builder then we never be able to fetch data for p.IsDeleted. am i right ?

please discuss each my points. thanks

Why EF create proxies

$
0
0

please tell me some one why EF need to create proxy....what is advantage of proxy?

public class BloggingContext : DbContext
{
    public BloggingContext()
    {
        this.Configuration.ProxyCreationEnabled = false;
    }

    public DbSet<Blog> Blogs { get; set; }
    public DbSet<Post> Posts { get; set; }
}

this way this.Configuration.ProxyCreationEnabled = false; we can disable proxy but i like to know if we disable proxy then what are the things will not be possible and what kind of problem will be started when disable proxy. thanks

How to implement EF in business layer

$
0
0

first of all give me link of article which guide how to implement EF in business layer.

next issue

tell me how to implement EF in business layer and we just call business layer from UI main layer and business layer will access EF to interact with data.

i have seen a sample code but do not understand why we need to declare two connection string one in app.config of business layer and one in web.config file of UI layer.

when EF is in BL layer then one connection string should be suffice in app.config file so why we need to separately mention the same connection string in web.config file of UI layer ?

anyone can explain this reason ?


Putting E-F connection in DAL (Class library) App.config file also requires connection string in MVC web.config file too??

$
0
0

I have a web app I'm working on that utilizes MVC 5 and E-F (version 6 I think).  Anyway, I moved my data objects (data connections and associated classes) to a DAL (data access layer) which I created as a new project in the same solution as the MVC app.  Since I'm using E-F, the connection string seems to be stored in the Application config file for the Class library.

However, I have found, to get it to work properly with the DAL and the MVC app, I must also put the Db connection string into the web.config file for the MVc app.  Doesn't this sort of defeat the purpose of having a DAL. I've been working with MVC for about 2 years now but am sort of new to the DAL concept (I understand it's purposes and why people use them, as in my case, I may want to use the same data objects in another app, so I implemented the DAL).

If this is not the correct way to do this, could I please get some assistance on how to get the DAL to work as it should and handle all database activities (connection string, data models, etc)?

I get The underlying provider failed to Open when using EF

$
0
0

This is the scenario:

In the web forms application using Entity Framework 6 and I have a /admin folder.

I have a LOGIN page that opens the Entity Framework connection on login:

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            bool userAuthenticated = (HttpContext.Current.User != null) && HttpContext.Current.User.Identity.IsAuthenticated;
            if (userAuthenticated)
            {
                if (!IsPostBack)
                {
                    // Open connection
                    if (dc.Database.Connection.State == ConnectionState.Closed)
                    {
                        dc.Database.Connection.Open();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Metodos.RegistrarLogErroSistema(ex);

            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Erro", "alert('" + (string.IsNullOrWhiteSpace(ex.Message) ? "Ocorreu um erro no sistema! Favor contactar o administrador." : ex.Message) + "');", true);
        }
    }


In the admin's Master Page I instantiate the datacontext and I have methods calling the database to check identity, group, permissions, like below:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin : System.Web.UI.MasterPage
{
    dbDIOEntities dc = new dbDIOEntities();

    public int getUserGroup
    {
        get
        {
            return Methods.getCurrentUserGroup().id;
        }
    }


And in the Method.cs inside the App_Code folder:


    public static grupos getCurrentUserGroup()
    {
        try
        {
            if (System.Web.HttpContext.Current.Session["ObjetoGrupoUsuario"] != null)
            {
                return (grupos)System.Web.HttpContext.Current.Session["ObjetoGrupoUsuario"];

            }
            else if (!string.IsNullOrWhiteSpace(HttpContext.Current.User.Identity.Name))
            {
                string nomeusuario = HttpContext.Current.User.Identity.Name.ToString();
                usuarios usuario = dc.usuarios.Where(o => o.username == nomeusuario).FirstOrDefault();
                return dc.grupos.Where(o => o.id == usuario.grupo_id).FirstOrDefault();
            }
            else if (System.Web.HttpContext.Current.Session["NomeUsuario"] != null)
            {
                string nomeusuario = System.Web.HttpContext.Current.Session["NomeUsuario"].ToString();
                usuarios usuario = dc.usuarios.Where(o => o.nome == nomeusuario).FirstOrDefault();
                return dc.grupos.Where(o => o.id == usuario.grupo_id).FirstOrDefault();
            }
            else
            {
                int IdOuvidoriaSetorial = (int)Enumeradores.GruposUsuarios.OuvidorSetorial;
                return dc.grupos.Where(o => o.id == IdOuvidoriaSetorial).FirstOrDefault();
            }
        }
        catch (Exception ex)
        {
            Metodos.RegistrarLogErroSistema(ex);
        }

        return null;
    }


And I have dozens of pages that Instantiate the datacontext and check user´s identity, group, permissions, etc.
As an example below I have "Search.aspx.cs" , that instantiates a new datacontext and uses it across the code behind page:

using System;
using System.Collections.Generic;
using System.Data.Entity.Validation;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Search : System.Web.UI.Page
{
    dbDIOEntities dc = new dbDIOEntities();



So users get error "The underlying provider failed to open" frequently and users can't use the web application.
Is is the proper way to instantiate datacontexts and open Entity connections ?
How could I change the code to avoid that error ? 



Directory lookup for the file mdf type failed with the operating system error 5(Access is denied.)

$
0
0

I am following the tutorial https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/adding-aspnet-identity-to-an-empty-or-existing-web-forms-project and https://www.codeproject.com/Articles/751897/ASP-NET-Identity-with-webforms for adding Identity Module in my existing web form project.

When trying to register any new user I am getting error as:

Server Error in '/' Application.
Directory lookup for the file "c:\users\scala\documents\visual studio 2015\Projects\RENTAL\RENTAL\App_Data\WebFormsIdentity.mdf" failed with the operating system error 5(Access is denied.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Directory lookup for the file "c:\users\scala\documents\visual studio 2015\Projects\RENTAL\RENTAL\App_Data\WebFormsIdentity.mdf" failed with the operating system error 5(Access is denied.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

I've Microsoft SQL Server 2014 installed and VS 2015 and my OS is Windows10. Most of the solutions said to allow permission for the App_Data folder, but I did not understand what kind of permission do I need to give.
My connection string

<connectionStrings><add name="DefaultConnection" connectionString="Data Source= DESKTOP-07C7H66;Initial Catalog=WebFormsIdentity;AttachDbFilename=|DataDirectory|\WebFormsIdentity.mdf;Trusted_Connection=Yes;Integrated Security=True" providerName="System.Data.SqlClient" /></connectionStrings> 

Please help me how can I solve this problem. Thank You!

I checked the following commands ::

PM> Get-Service | Where-Object {$_.Name -like '*SQL*'}

Status   Name               DisplayName
------   ----               -----------
Running  MSSQLFDLauncher    SQL Full-text Filter Daemon Launche...
Running  MSSQLSERVER        SQL Server (MSSQLSERVER)
Running  MSSQLServerOLAP... SQL Server Analysis Services (MSSQL...
Stopped  SQLBrowser         SQL Server Browser
Stopped  SQLSERVERAGENT     SQL Server Agent (MSSQLSERVER)
Running  SQLWriter          SQL Server VSS Writer


PM> SqlLocalDb info
MSSQLLocalDB
PM> 

Then changed my connection sting to 

<connectionStrings><add name="DefaultConnection" connectionString="Data Source= .\SQLEXPRESS;Initial Catalog=WebFormsIdentity;AttachDbFilename=|DataDirectory|\WebFormsIdentity.mdf;Trusted_Connection=Yes;Integrated Security=True" providerName="System.Data.SqlClient" /></connectionStrings>

getting error as::

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Again I tried changing the connection string as ::

<connectionStrings><add name="DefaultConnection" connectionString="Data Source=MSSQLLocalDB;Initial Catalog=WebFormsIdentity;AttachDbFilename=|DataDirectory|\WebFormsIdentity.mdf;Trusted_Connection=Yes;Integrated Security=True" providerName="System.Data.SqlClient" /></connectionStrings>

then get anther error::

 Invalid value for key 'attachdbfilename'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'.

I can not understand how to solve this problem. Please help!!!

EDMX Decimal causing data issue

$
0
0

I am having real datatype in Sql and when generated edmx the datatype is decimal for that column and when i enter the value like 12.3 its saving in DB as 12.xxxxxxxx. How to store exactly what user enters. The issue is while assigning to edmx datatype only.

What does mean the multitenant application with Entity Framework

$
0
0

i do not understand what is  multitenant application ?

is it something like we have sold our ER system to multiple client and application hosted in cloud so anyone can access ERP from any where. say for example our ERP system sold to company1 and company2. both company has few users who will access our ERP. there would be two database for each company. this kind of application is called multitenant application ?

generic repository and multiple column sort

$
0
0

this is very simple way to sort by multiple column.

var qry = ctx.DestinationTimings.Where(x => x.DestinationID == this.ID)
                 .OrderBy(t => t.Date ?? DateTime.MaxValue)
                 .ThenBy(t => t.DayOfWeek)
                 .ThenBy(t => t.Time);

i like to know suppose when we work with generic repository then how could i sort multiple columns easy way. suppose first column asc order and next two columns desc order. suppose table has 10 columns.

please give me a easy and simple solution. thanks

LINQ - How to write LINQ query to split and find the column min and maximum and return based on string values.

$
0
0

Hi,

How to write LINQ query to split and find the column min and maximum and return based on string values.

I done some code using LINQ, but it is not working.

what is the problem in my code.

Scenario is,

1. Split the string and find the column

2. Check the minimum and maximum range of each splitted string. (SUB C=100#SUB D=200)

3 range should check within the limit like 100 min and max

protected void Button_Click(object sender, EventArgs e)
    {


        string string1 = "SUB C=100#SUB D=200";

        string FinalOutput = "GRADE#SUB B";

        DataTable dt = new DataTable();
        dt.Columns.AddRange(new[] { new DataColumn("Studentno"),new DataColumn("GRADE"),new DataColumn("SUB B"), new DataColumn("SUB C(MIN)"), new DataColumn("SUB C(MAX)"),
new DataColumn("SUB D(MIN)") ,new DataColumn("SUB D(MAX)") ,new DataColumn("SUB C"),new DataColumn("FROM"),new DataColumn("TO") });
        dt.Rows.Add(101,"A", "100", "100", "200", "200", "300", null, 20, "100");
        dt.Rows.Add(101, "B", "100", "150", "250", "250", "350", null, 20, "100");
        dt.Rows.Add(101, "B", "100", "200", "300", "100", null, null, 20, "100");
        dt.Rows.Add(101, null, "100", "200", "300", "100", null, null, 20, "100");



        //Check whether a given column name exists or not


        string[] word1 = string1;

        List<string> FinalResult = new List<string>

        for (int i = 0; i < word1.Length; i++)
        {

            string ChkDim = word1[i];

            var results = (from row in dt.AsEnumerable()
                           from pair in
                               (from term in ChkDim.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                let pair = term.Split(new[] { '=' })
                                where pair.Count() == 2 && int.TryParse(pair[1], out dimens)
                                select new KeyValuePair<string, int>(pair[0], dimens))
                           where row[pair.Key + "(MIN)"] != DBNull.Value && row[pair.Key + "(MAX)"] != DBNull.Value
                           let r1 = Convert.ToInt64(row[pair.Key + "(MIN)"])
                           let r2 = Convert.ToInt64(row[pair.Key + "(MAX)"])
                           let FrSize = Convert.ToDouble(row.Field<double>("FROM SIZE"))
                           let ToSize = Convert.ToDouble(row.Field<double>("TO SIZE"))
                           where pair.Value >= r1 && pair.Value <= r2 &&

                           PipeDia >= FrSize && PipeDia <= ToSize
                           select new
                           {

                                FinalValue = row[column] // Need to get column value. Output is GRADE=A and SUB B=100

                           }).Distinct();


            FinalResult.Add(word1[i] + "=" + FinalValue);

        }

        //finally Result





    }

 

My final output should return in in the List.
[0] GRADE=A
[1] SUB B=100

what is the problem in my code...


Filtering

$
0
0

I have a two related tables.

public partial class Companies

{
public Companies()
{
ContactsNavigation = new HashSet<Contacts>();
}

public int Id { get; set; }
public string Inn { get; set; }
public string MainName { get; set; }
public string Name { get; set; }
public string Place { get; set; }
public string Contacts { get; set; }
public string Notes { get; set; }
public int Rate { get; set; }
public string Comments { get; set; }
public string Responsible { get; set; }
public bool? Favorites { get; set; }

public ICollection<Contacts> ContactsNavigation { get; set; }
}

and 

public partial class Contacts
{

public int Id { get; set; }

public string NameFio { get; set; }
public string PhoneNumber { get; set; }
public string Mail { get; set; }
public string Username { get; set; }
public int? IdofMedInst { get; set; }
public int? IdofCompanies { get; set; }
public string Position { get; set; }

public Companies IdofCompaniesNavigation { get; set; }
}

Than I create "CompaniesController" with filtering

IQueryable<Companies> Company = _context.Companies.Include(c => c.ContactsNavigation);

if (!String.IsNullOrEmpty(CompaniesInput))
{
Company = Company.AsQueryable().Where(p => p.Inn.Contains(CompaniesInput) ||
p.Name.Contains(CompaniesInput) || p.Contacts.Contains(CompaniesInput));
}

Is there any way to find all Companies where Contacts (from table Contacts) contain  data from "CompaniesInput" ?

Model vs. Entity

$
0
0

I was wondering what is the difference between a model and an entity in the entity framework. Thank You In Advance.

update master with sum record of details

$
0
0

hello

i have created solution in visual studio 2012 and this solution is layred in 4 project :

1. project presentation layer (asp.net mvc) 

2. business entities layer

public class Master
{
   public int Id {get; set;}
   public decimal TotalPrice {get; set;}
   //the rest of properties
   public private ICollection<Detail> Details {get; set;}
}

public class Detail
{
  public int Id {get; set;}
  public decimal UnitePrice {get; set;}
   //the rest of properties
  public int MasterId {get; set;}
  public private Master Master {get; set;}
}

3. data access layer (ado.net data model entity framework + repositories)

public class MasterRepository : IMasterRepository{
    //code of class to implemente GetAll + CRUD for master
}


public class DetailRepository : IDetailRepository{

   EFContext context = new EFContext();

  //Get the details for one master

   public IEnumerable<Detail> GetAllDetailsByMasterId(int masterId)
   {
      var query = context.Details.Where(d=>d.MasterId == masterId)
   }

  //the rest of code to implemente CRUD of details

}

4. but for business logic layer in classes Bll i try to calculate the total of the master by sum of unit prices for the details

public class MasterDetailsBll
{

   public decimal GetTotal(){

//call the methode GetAllDetailsByMasterId of DetailRepository thet return enumerebal<detail> and then call the extention methode Sum for calculate the sum of unite prices of detail

       using (var repository = new DetailRepository())
       {
         var total = reopsitory.GetAllDetailsByMasterId(masterId).Sum(d=>d.UnitePrice);
       }

//call the CRUD Mehodes of repositoryMaster and CRUD of the repositoryDetails } }

I am a beginner in .net and I do not know if working with a layered application is a good idea or not.

How I update total of master with sum of unit price after each insert/update of detail?

please help me

Please help me with using FOR loop on Entity

$
0
0

Sorry to bother... I'm learning c# and found a problem that I don't know how to resolve... its about Entity connection to a local table... now I can loop using FOREACH... by curiosity I tried to make it using FOR instead... I get an ugly error... I can't refer to the item or member as Tabla[INDEX] as I usually do with Lists NOR can use the ElementAt(INDEX)... would you please tell me how to point to an specific item on my Table? thank for your help!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LocalDbExample
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            conexionACME miConexion = new conexionACME();

            var Tabla = miConexion.Customers;

            for (int i = 0; i < Tabla.Count<Customer>(); i++)
            {
                Customer myCS = Tabla.ElementAt<Customer>(i); ------------------> HERE'S THE ERROR!! HOW TO GET ITEM?

                resultLabel.Text += $"{myCS.CustomerID}<br>";

            }

        }
    }
}



LINQ Best use for selectmany

$
0
0

please show me small example of selectmany which guide me in which situation people use selectmany. thanks

Viewing all 1698 articles
Browse latest View live


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