Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 3 New Entity Framework Tests #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*.suo
bin/
obj/
/*.user
20 changes: 17 additions & 3 deletions Tests/PerformanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ static DataClassesDataContext GetL2SContext()
return new DataClassesDataContext(Program.GetOpenConnection());
}

private static Func<EntityFramework.tempdbEntities1, int, EntityFramework.Post> entityFrameworkCompiled = System.Data.Objects.CompiledQuery.Compile<EntityFramework.tempdbEntities1, int, EntityFramework.Post>((db, id) => db.Posts.First(p => p.Id == id));

public void Run(int iterations)
{
var tests = new Tests();
Expand All @@ -89,15 +91,27 @@ public void Run(int iterations)

var entityContext2 = new EntityFramework.tempdbEntities1();
entityContext2.Connection.Open();
tests.Add(id => entityContext.ExecuteStoreQuery<Post>("select * from Posts where Id = {0}", id).ToList(), "Entity framework ExecuteStoreQuery");
tests.Add(id => entityContext2.ExecuteStoreQuery<Post>("select * from Posts where Id = {0}", id).ToList(), "Entity framework ExecuteStoreQuery");

var entityContext3 = new EntityFramework.tempdbEntities1();
entityContext3.Connection.Open();
tests.Add(id => entityFrameworkCompiled(entityContext3, id), "Entity framework CompiledQuery");

var entityContext4 = new EntityFramework.tempdbEntities1();
entityContext4.Connection.Open();
tests.Add(id => entityContext4.Posts.Where("it.Id = @id", new System.Data.Objects.ObjectParameter("id", id)), "Entity framework ESQL");

var entityContext5 = new EntityFramework.tempdbEntities1();
entityContext5.Connection.Open();
entityContext5.Posts.MergeOption = System.Data.Objects.MergeOption.NoTracking;
tests.Add(id => entityContext.Posts.First(p => p.Id == id), "Entity framework No Tracking");

var mapperConnection = Program.GetOpenConnection();
tests.Add(id => mapperConnection.ExecuteMapperQuery<Post>("select * from Posts where Id = @Id", new { Id = id }).ToList(), "Mapper Query");

var mapperConnection2 = Program.GetOpenConnection();
tests.Add(id => mapperConnection2.ExecuteMapperQuery("select * from Posts where Id = @Id", new { Id = id }).ToList(), "Dynamic Mapper Query");


var massiveModel = new DynamicModel(Program.connectionString);
var massiveConnection = Program.GetOpenConnection();
tests.Add(id => massiveModel.Query("select * from Posts where Id = @0", massiveConnection, id).ToList(), "Dynamic Massive ORM Query");
Expand Down Expand Up @@ -213,4 +227,4 @@ public static Nullable<T> GetNullableValue<T>(this SqlDataReader reader, int ind
return null;
}
}
}
}