( Expression. Equal( Expression. Property(para..." />

Using delete on a LINQ to Sql Data Context with an Interface - 'Interface is not mapped as a table?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

But something like: var param = Expression. Parameter(typeof(T), "x"); var lambda = Expression. Lambda>( Expression.

Equal( Expression. Property(param, "Key"), Expression. Constant(instance.

Key) ), param) This then isn't bound to IFileData but to T It will fail, however, if IFileData. Key is implemented via explicit interface implementation - there must be an obvious Key field/property on T Then: var table = db.GetTable(); var obj = table. SingleOrDefault(lambda); if(obj!

= null) table. DeleteOnSubmit(obj); db.SubmitChanges().

But something like: var param = Expression. Parameter(typeof(T), "x"); var lambda = Expression. Lambda>( Expression.

Equal( Expression. Property(param, "Key"), Expression. Constant(instance.

Key) ), param); This then isn't bound to IFileData, but to T.It will fail, however, if IFileData. Key is implemented via explicit interface implementation - there must be an obvious Key field/property on T. Then: var table = db.GetTable(); var obj = table.

SingleOrDefault(lambda); if(obj! = null) table. DeleteOnSubmit(obj); db.SubmitChanges().

Thanks for your reply. The code does not compile on the second Expression (Expression>), it says 'Class name is not valid at this point. '.

– Stephen Wells Aug 22 at 23:01 Thanks for your reply. The code does not compile on the second Expression (Expression>), it says 'Class name is not valid at this point. '.

The delete extension method is from CodeSmith, which basically turns your lambda into SQL and does a batch delete. I'll change it to use DeleteOnSubmit(instance). (apparently I spent more than 5 minutes editing my comment :() – Stephen Wells Aug 22 at 23:10 @Stephen gah!

I missed the . Lambda!. See edit.

– Marc Gravell? Aug 22 at 23:32 Ok great but what do I do with my lambda? I'm not that familiar with expression trees.... (also I changed the question a little, any chance you could update the answer?

:)) – Stephen Wells Aug 22 at 23:41 @Stephen updating – Marc Gravell? Aug 227 at 6:11.

I have three entities in my data context which inherit IFileData, but I want just a single delete method. How can this be achieved? The code below give the error The type "IFileData" is not mapped as a Table.

The only solution I have so far is to do a switch on the .GetType() which is a bit messy.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions