Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6727481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:03:17+00:00 2026-05-26T10:03:17+00:00

Hi I use MySQL Connector/Net 6.3.5 and Entity Framework 4.1. In DB I have

  • 0

Hi I use MySQL Connector/Net 6.3.5 and Entity Framework 4.1.

In DB I have table with arround 320 000 rows I do simple query by column.

I have litlle problem with performance. It exist some technique or methods how speed up query?

Query timeout is about 6.3 seconds, server is not local.

Here is method which I use :

/// <summary>
/// select podla kluca
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public TEntity SelectByKey(string key)
{
    // First we define the parameter that we are going to use the clause.
    var xParam = Expression.Parameter(typeof(TEntity), typeof(TEntity).Name);
    MemberExpression leftExpr = Expression.Property(xParam, KeyProperty);
    Expression rightExpr = Expression.Constant(key);
    BinaryExpression binaryExpr = Expression.Equal(leftExpr, rightExpr);

    //Create Lambda Expression for the selection
    Expression<Func<TEntity, bool>> lambdaExpr = Expression.Lambda<Func<TEntity, bool>>
        (binaryExpr, new ParameterExpression[] { xParam });

    //Searching ....
    IList<TEntity> resultCollection = ((IRepository<TEntity, TCtx>)this).SelectAll(new Specification<TEntity>(lambdaExpr));

    if (null != resultCollection && resultCollection.Count() > 0)
    {
        //return valid single result
        return resultCollection.First();
    }
    return null;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:03:17+00:00Added an answer on May 26, 2026 at 10:03 am

    How About replacing your last few lines (Sorry I have not tested it) but just from top of my head.

    IList<TEntity> resultCollection = ((IRepository<TEntity, TCtx>)this).SelectAll(new Specification<TEntity>(lambdaExpr));
    ((IRepository<TEntity, TCtx>)this)
    if (null != resultCollection && resultCollection.Count() > 0)
    {
       //return valid single result 
       return resultCollection.First();
    }
    return null;
    
    // with following lines
    
    foreach(TEntity entity in ((IRepository<TEntity, TCtx>)this).SelectAll(new Specification<TEntity>(lambdaExpr)))
        return entity;
    return null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application in which I use entity framework with mysql connector/net
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
I'm trying to use MySQL (5.5.22, Connector 6.5.4) with Entity Framework 4. I'm using
I installed MySQL connector for .Net v6.5 and it is supported by Entity Framework.
I use visual studio 2010-12 and I installed ADO.NET Entity Framework 4.1 , Mysql
I'm using the C# .NET Mysql Connector, and when running this query: INSERT INTO
Should I use the native .NET connector for MySQL? Or should I use the
I'm trying to use the MySQL Connector/Net to connect a c# program to a
I have .NET MVC 3 project where I use sql membership provider and entity
Is it possible from ASP .NET through the latest MySQL .NET connector to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.