问题
Is there a reasonable way to access FoxPro databases using LINQ?
回答1:
One the blessing/curses of .NET is that the answer is rarely "no" to any .NET programming question.
For example, this guy (thanks Sergey and Larry) shows a way to access FoxPro-type DBs with LINQ: http://blogs.msdn.com/calvin_hsia/archive/2007/11/30/6620133.aspx
A better question is probably, not can you, but should you!?
If you insist on such an option, the Entity Framework is probably a better place to look: http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx
回答2:
I just finished working on implementation. http://linqtovfp.codeplex.com/
回答3:
Linq2Sql only supports Sql Server, Entity framework supports a bunch, but foxpro is not one of them.
NHibernate has a Linq provider that just went 1.0, and with a bit of jiggering you can get it working with Foxpro.
IMO NHibernate.Linq is your best bet, but it all depends on how you define "reasonable" ;-)
回答4:
I'm working in this general area at the moment - trying to connect Silverlight to legacy data in VFP9 tables and so on.
You might find it easier to take a Web Services approach. This would involve creating a COM server DLL using Visual FoxPro that has methods to access the VFP data and return them using CursorToXML() in a format that .NET can load into a DataSet or DataTable. CursorToXML can do that on its own. You would then create a WCF Web Service project in .NET, and add the COM DLL created by VFP into that project - you're using COM Interop here. Then you create WebMethods in your WCF service that map to method calls on the VFP DLL. Once it's in a WCF Service you can use that service as a data source. Not the fastest way of doing things, perhaps, but it works.
Rick Strahl has an excellent article demonstrating all this in Code Magazine.
来源:https://stackoverflow.com/questions/334930/linq-with-foxpro