Linq to MySql GetTable - c#

I am trying to insert/add a data into my Database but it seems that this part of code won't work The name of the table that I am trying to add data on is "People"
Table<People> users = myDb.GetTable<People>;
Has an error on the Table<People> users why is this error occurring?? how would I fix this?
just in case you need the stack trace, here it is.
Error 1
The type or namespace name 'Table' could not be found (are you missing a using directive or an assembly
reference?)
C:\Users\John\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 23 13 WindowsFormsApplication1

You need to add
using System.Data.Linq;
to the top of your file to bring the Table class into scope. Alternatively you could use:
var users = myDb.GetTable<People>();

Related

USQL - Custom Outputter failed to find NewtonSoft

I have a USQL Job which reads json from Azure Blob and after some data manipulation writes a single line JSON file to ADLS.
I have written a Custom Ouputter to write JSON File.
This is how my CustomOutputter files look like:
using Microsoft.Analytics.Interfaces;
using Microsoft.Analytics.Types.Sql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
namespace demo{
[SqlUserDefinedOutputter(AtomicFileProcessing = true)]
public class JSONOutputter : IOutputter
{
//Actual Code Here
public static class Factory
{
public static JSONOutputter JSONOutputter(bool isHeader = true, Encoding encoding = null)
{
return new JSONOutputter(isHeader, encoding);
}
}
}
I am using this Ouputter in my USQL Job like this:
OUTPUT #final_output
TO "/output/json/final.json"
USING demo.Factory.JSONOutputter(isHeader: true);
When I compile my USQL Script using
ADL: Compile Script
I get this error:
[Info] Start compiling code behind: /users/kumar.pratik/documents/usql/second.usql.cs ...
[Error] Command failed: mono /Users/kumar.pratik/.vscode/extensions/usqlextpublisher.usql-vscode-ext-0.2.11/compilehost/compilehost.exe /users/kumar.pratik/documents/usql/second.usql.cs /Users/kumar.pratik/Documents/usql/usqlCodeBehindReference /Users/kumar.pratik/Documents/usql/second.usql.dll __codeBehind__tRYGlFBeSWcl
[Error] Compile failed
error: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" at line: 8, column 6
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 17, column 12
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 44, column 34
Could someone please let me know how can I get this fixed?
I am working on Visual Studio Code on Mac OS
Thanks
Can you please share how your script looks like? In particular, are you
Using Visual Studio's code behind for your Outputter code?
If the answer to 1 is no: Did you register your Outputter and Newtonsoft lib in the U-SQL catalog with CREATE ASSEMBLY or via the Visual Studio Assembly registration feature? And did you reference the U-SQL assemblies (both your own code and Newtonsoft) in your script with REFERENCE ASSEMBLY?
More details: https://blogs.msdn.microsoft.com/azuredatalake/2016/08/26/how-to-register-u-sql-assemblies-in-your-u-sql-catalog/

VS 2017 cannot detect ADStoreCtx n code but does in the watch

I am trying to get the user.UserPrincipalName by using the System.Web.HttpContext.Current.User.Identity.Name.
I have the following code:
string[] parts = System.Web.HttpContext.Current.User.Identity.Name.Split(new char[] { '\\' });
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
_log.Info($"DNS Domain={((System.DirectoryServices.AccountManagement.ADStoreCtx)ctx.userCtx).DnsDomainName}");
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, parts[1]);
return user.UserPrincipalName;
While using the VS 2017 watch on the ctx object (after 2nd row assignment) I got the DnsDomainName which I would like to log.
BUT, When I try to copy the expression which extracts the value and put it in code I get the following error:
The type or namespace name 'ADStoreCtx' does not exist in the namespace
'System.DirectoryServices.AccountManagement' (are you missing an assembly reference?).
There is no "Suggested fix" for it.
I am trying to figure out how come that in the "watch" it does have this but not in the code. What reference should I add or what needs to be configured so I'll be able to access the property I am searching for ("DnsDomainName").
By the way, The ctx.Name and ctx.Username are nullso I cannot use them.
Thanks in advance,
Yosy
p.s.: I have the using statements for both:
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;

Object in ProjectReference not accessible when using 'Import'

In a simple project i want to reference objects from a webreference added to another c# library.
The Webreference is called QServices The default namespace is set as below
What seems to work is the following code:
Taskworkflow.SI.QServices.Record[] querysResult = new Taskworkflow.SI.QServices.Record[0];
yet when i import the Taskworkflow.SI - namespace, i keep on getting errors:
using TaskWorkflow.SI;
....
QServices.Record[] querysResult = new QServices.Record[0];
This results in the error:
The type or namespace name 'QServices' could not be found (are you missing a using directive or an assembly reference?)
Could someone clarify this for me?
Thank you for your time.
Note: QServices do only exist inside TaskWorkflow.SI. They do not have any occurences in other projects nor do they have any classes/namespaces/objects that share the name.
I strongly suspect that for whatever reason, you're ending up with a namespace called QServices declared in the TaskWorkflow.SI namespace. So actually you want:
using TaskWorkflow.SI.QServices;
....
Record[] querysResult = new Record[0];
Or you could explicitly alias it:
using QServices = TaskWorkflow.SI.QServices;
....
QServices.Record[] querysResult = new QServices.Record[0];

Type or Namespace Error

I have two references in my application. In the BAL code i am able to use the namespace "using TestDAL;"
But I am not being able to use the namespace of BAL in my .cs page. This is the error i get,
CS0246: The type or namespace name 'TestBAL' could not be found (are
you missing a using directive or an assembly reference?)
And one thing in my bin folder too I only have the TestDAL.dll file. How do I insert TestBAL.dll file?
Can anyone help me with what can be possible reason?
Thanks in Advance,
Try this:
Then, click browse and add your .dll file:
That should help you, if not please leave some feedback.
You could also try using alias for your namespace like this:
using namespaceAlias = TestBAL;
Create object of TestBAL objBAL = new TestBAL(); in your cs page. Check out, This codes gives any error or not.

Using form setting in WinForm

Hi I want to use applications Settings to retrieve some default properties of my WinForm
and I've also included using WinForm.Properties .
But I get this error
Error 1 'WF_Certificate.Properties.Settings' does not contain a
definition for 'BaudRate' and no extension method 'BaudRate' accepting
a first argument of type 'WF_Certificate.Properties.Settings' could be
found (are you missing a using directive or an assembly
reference?) C:\Users\saadat\Documents\Visual Studio
2012\Projects\WF_Certificate\WF_Certificate\Form1.cs 44 41 WF_Certificate
on this line:cmbBaudRate.Text = settings.BaudRate.ToString();
note : I declared
SerialPort comport = new SerialPort();
and
Settings settings = Settings.Default;
I'm confused . Am I missing something?
If your settings class name is Settings1, then you can use:
cmbBaudRate.Text = Settings1.Default.BaudRate;
You do not need to do anything else. Make sure you have created the BaudRate setting first.

Categories