Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

IoC Interface Template #123

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've created an IoC interface template that I hooked into the Entities.cst 
which generates a nice interface to the context. Showed it to Eric. Let me 
know what you think.

-Tyler 

Original issue reported on code.google.com by tyler.je...@gmail.com on 17 Aug 2009 at 7:13

Attachments:

GoogleCodeExporter commented 9 years ago
WARNING! I've since found that LINQ to SQL emits different SQL at times if the 
context object is declared as the interface. So I have abandoned the use of 
this 
concoction.

Original comment by tyler.je...@gmail.com on 27 Aug 2009 at 4:20

GoogleCodeExporter commented 9 years ago
What did you end up going with?  Is there another solution to this problem?

Original comment by shannon....@gmail.com on 28 Aug 2009 at 4:09

GoogleCodeExporter commented 9 years ago
http://blogs.msdn.com/mattwar/archive/2008/05/04/mocks-nix-an-extensible-linq-to
-sql-
datacontext.aspx 

With a minor fix to support the IDisposable Dispose method call:

//fix from original: check for IDisposable as well as the IProvider calls
if ((call.MethodBase.DeclaringType.Name == "IDisposable" || 
call.MethodBase.DeclaringType.Name == "IProvider") && 
call.MethodBase.DeclaringType.IsInterface)

It's not terribly pretty, but it does allow you to "mock" or "fake" the context 
in a 
test.

Original comment by tyler.je...@gmail.com on 28 Aug 2009 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 18 Sep 2009 at 4:47