How do I use LinqPad for updates with CRM 2011 - linq

I am working with linqpad and crm 2011, cloud version, and C# snippets. Simple select queries work as advertised. Nonetheless for linqpad to be of any real use I need to get it to do updates and inserts as well and have not been able to find sample code which works or come up with any real information. Several kinds of things which show up in sample code I see around the net are missing. in particular, TestDataContext appears to be part of one or more assemblies which get loaded with linq-sql projects in Visual Studio, but is not in evidence on linqpad. SubmitChanges is not there, and it is not clear what I'd have to do to get at it or to instantiate a new DataContext object and try to use its submitchanges method.
Any usable information would be appreciated.

Well I don't know the CRM 2011 LINQ implementation. Does LINQPad have direct support for that?
Anyway, you basically can run any C# code in LINQPad. Here's a step-by-step guide how to run the needed code:
You need to add the required framework assemblies (maybe take a look at your Visual Studio project). To achieve this, go to the ‘Query’->’Advanced Query Properties’. On the dialog, click on ‘Add…’, then on ‘Browse…’. Browse to the assemblies. Add the required assemblies. Keep the ‘Advanced Query Properties’-dialog open for the next step. Optinally add your own assemblies when you use types from it.
In the ‘Advanced Query Properties’-dialog go the tab ‘Additional Namespace Imports’. Add there the namespaces you need. Expecially the LINQ-namespaces of your LINQ-provider.
Click on ‘Set as default for new queries’ so that you don’t need to repeat the three steps above next time. Then we’re done.
Now you can use the LINQ-provider in LINQ-Pad. Use the 'C#-Statements'-language. Use the .Dump-method to view query results.
Now with that steps you can use any API in LINQPad. With that you can do loops and use the regular API to update objects.

Here's what worked for me in Linqpad for CRM.
Remember that the context is implied in Linqpad.
Create your new entity and load its data, then:
AddObject(entityName);
SaveChanges();

Related

Is there a view/widget to show details of language elements in Visual Studio?

In Eclipse, there is a view called "ABAP Element Info", which can show details about language elements such as functions, classes, etc. when they are clicked on. It will display details such as function/method signature, class/struct members, element documentation, etc. as you can see on the image below:
It is a great help for me and it's very quick to find out details of elements, but I cannot find anything like it in Visual Studio standard package (except Object Browser, but I does not show what I click on, I need to look it up). Is there any extension or something with similar functionality I could make use of? I'm using C++ desktop version if it helps. Thanks a lot for any input.
Instead of using Visual Studio, try to check if your project is fully supported and operational in Visual Studio Code.
In VSCode there are various plugins for ABAP development, including syntax highlighting which is your main concern.
Check out the following article on how to prepare your environment:
https://blogs.sap.com/2019/12/06/abap-development-in-vs-code/

Telerik Data Access generate classes automatically

Until the recent release I was happily using Telerik Data Access in a database first way:
Created the database schema in external DB designer
Generated a fluent model in Visual Studio
Whenever I did a database change I either re-ran the generation or updated models via visual designer depending on the magnitude of the change
After the last release the templates I used for the generation are gone (as is the visual designer) and any attempt at Googling the solution takes me to a Telerik documentation page saying the info is deprecated.
I'm working with large existing databases (100+ tables) and there's no way I'm coding the models by hand.
What are the current options for auto generating the models?
I got a reply on Telerik forums. Simply said there's nothing I can do now and have to wait til/if they develop a solution. For all that are interested, please vote on the feature request.
Here's the reply:
Thank you for your feedback.
We have already created a new feature request (http://feedback.telerik.com/Project/114/Feedback/Details/163155-generation-of-fluent-models-with-data-access-q2-2015-and-higher) to create a code generating tool to create your fluent models based on your database schema. You are welcome to cast your support vote for the item.
I cannot give you any time frame when we will be able to ship such tool, but I will make sure to notify you as soon as we have a public release.
Regards,
Viktor Zhivkov
Telerik
The feature is still not available. But maybe this is an alternative to being stuck with VisualStudio 2013.
Owners of VisualStudio Enterprise have another option. They can modify the code generation templates and generate the fluent metadata and context code from an UML class diagram.
I invested in checking the MSDN documentation and created a VS extension which I open-sourced.
Please check https://github.com/bdongus/UMLExtensions for details. Feel free contribute.

Visual Studio 2010/Resharper Plugin development

I am having trouble tracking down information regarding extending Intellisense. It looks like creating a plugin for VS 2010 or Resharper would do the trick. However, I can't find any documentation for adding items to the intellisense dropdown.
This post got pretty close: How to extend IntelliSense items?
But I couldn't find any documentation for the interfaces or classes being used.
What I am trying to do is to read from an XML file, and add those tags as part of the results that show up in intellisense in the C# code (not in XML).
The part of the R# Plugin Development Guide concerning Code Completion (i.e., IntelliSense) is on our todo list but has not yet been written. When done, it should be available here. While we're working on that, feel free to email me dn at jetbrains dot com, and I'll try to help you out with any queries you might have.

NhQueryable LINQ extension methods?

Solution
I needed to update Nhibernate from version 3.1.0.4000 to 3.2.0.4000. My guess is that only 3.2+ has the extra Nhqueryable LINQ support. Btw, I am using NhQueryable because it appears to bind to JqGrid much faster that a regular IQueryable: better performance for JqGrid, hurrah!
Original Issue
Not sure my terminology or understanding is up to snuff to be able to ask this clearly:
I'm using asp.net, mvc3, and nhibernate(fluent). On one project I'm maintaining, I'm able to use LINQ extension methods (such as .Where()) with NhQueryable objects. On a second project, the only NhQueryable method available is .As<>().
What configuration/library/class am I missing in the second project? Nothing stands out to me in the first project where NhQueryable can use the LINQ extension methods.
Check that both projects are referencing the same version of NHibernate, one might be using an older version which does not have linq support.
If they are both using the same version, check that the correct namespaces have been added or you won't see the extension methods in Visual Studio.

Need to debug LINQ simple queries in Visual Studio 2010

I often get in a position when I need to know why my LINQ doesnt work as intended...
I use object collections and extensions.
I dont want spend more than couple of minutes on it. LINQ supposed to make developer's life easier not harder.
I hoped VS 2010 will have it fixed but I now use RC and it still doesnt let me type LINQ and check what is going on... Says as before "Expression cannot contain lambda expressions"...
Is there some add-on for Visual Studio so I can quickly and effectively run ad-hoc queries and find out what is going on and where I am wrong?
It's not a VS plugin, but it's free and it's awesome: LinqPad
Check it out here
You can run whatever linq or code snippet in general, just give it a look, it's an incredibly useful tool, for linq and more.
Have you tried this?
Debugging LINQ Queries
Debugging LINQ queries can be
problematic. One of the reasons is
that quite often, you write a large
query as a single expression, and you
can’t set a breakpoint mid-expression.
Writing large queries in expression
context is particularly powerful when
using functional construction to form
XML (or using the strongly typed DOM
in Open XML SDK V2). This post
presents a little trick that makes it
easier to use the debugger with LINQ
queries that are written using ‘method
syntax’.
VS 2010 isn't going to address this..
There is, in fact, such a plugin as you describe, but unfortunately it is highly expiremental. You will probably need to install VS2008 SDK and the Service Packs to get it to work - I know I did..
Here is the link:
http://extendedimmediatewin.codeplex.com/

Resources