I have an issue with my Linq to SQL Data Context no submitting in my console application.
The following code is all that there is in the main() method.
BlogRollerDataContext bdc = new BlogRollerDataContext();
bdc.Urls.InsertOnSubmit(new Url()
{
Approved = false,
UrlTo = "http://www.google.com/",
UrlFrom = ""
});
bdc.SubmitChanges();
This might help you.
Related
We are trying to extract data from a checkbox using the Form recognizer. We have a custom model where we extract 4 fields. All fields get extracted except one ("has_observations").
We used the analyze tab on fott-2-1.azurewebsites.net and it shows correctly for all the files we are trying to do OCR on.
private static FormField GetField(this RecognizedFormCollection forms, string fieldName)
{
FormField field = null;
foreach (RecognizedForm form in forms)
{
if (form.Fields.ContainsKey(fieldName) && form.Fields[fieldName] != null)
{
field = form.Fields[fieldName];
logger.LogWarning("values is=" + field.ValueData.ToString());
break;
}
}
return field;
}
The field is "Azure.AI.FormRecognizer.Models.FormField" for "has_observations" label everytime and we have no idea how to fix it.
Which version of FormRecognizer SDK are you using? 3.1.1? You maybe calling different version from website vs from SDK.
If you are using 4.0.0-beta.X, by default it calls 2022-01-30-preview version of FormRecognizer APIs (see https://azuresdkdocs.blob.core.windows.net/$web/dotnet/Azure.AI.FormRecognizer/4.0.0-beta.3/index.html), but based on the screenshot you are using 2.1. So, API results maybe different between versions.
A few other troubleshooting options to see exact URLs and responses for http traffic from FormRecognizer SDK:
Logging with the Azure SDK for .NET, I.e. line below starts printing to the console each request/response.
var listener = AzureEventSourceListener.CreateConsoleLogger(EventLevel.Informational);
Some information will be redacted in logs. Changes to ClientOptions below will show more data (see details in Azure SDK diagnostics):
var frOptions = new FormRecognizerClientOptions() { Diagnostics = { IsLoggingContentEnabled = true, LoggedHeaderNames = { "*" }, LoggedQueryParameters = { "*" }}};
var client = new FormRecognizerClient(new Uri(endpoint), credential, frOptions);
Does the MongoDB C# driver support query interceptors like Entity Framework?
I've checked the documentation but can't find anything.
Basically what I need to do is ensure that certain queries to the database, depending on context, always have certain restrictions applied.
For example, if my documents can be soft deleted then I always need to make sure a filter is added for { "SoftDeleted": false }. Entitity Framework handles this gracefully via query interceptors.
MongoClient allows subscribing to CommandStartedEvent. Here is a sample that dumps to console each command sent to the server:
var mongoClient = new MongoClient(new MongoClientSettings
{
Server = new MongoServerAddress("localhost", 27017),
ClusterConfigurator = cb =>
{
cb.Subscribe<CommandStartedEvent>(e =>
{
Console.WriteLine($"{e.CommandName} - {e.Command.ToJson(new JsonWriterSettings { Indent = true })}");
Console.WriteLine(new String('-', 32));
});
}
});
CommandStartedEvent contains CommandName and Command properties that you could use for your specific logic.
Hi Im Trying to create a DataBase in MongoDB from C# code This is the code Im Useing
public partial class SqlToMongo : Form
{
public SqlToMongo()
{
InitializeComponent();
connectToMongo();
}
public void connectToMongo(){
var con = "mongodb://127.0.0.1";
MongoClient client = new MongoClient(con);
var db = client.GetDatabase("BetsOdds");
bool d = db.RunCommandAsync((Command<BsonDocument>)"{ping:1}")
.Wait(2000);
var Betsodds = db.GetCollection<BetOdds>("Betodds");
}
}
The ping return true when MongoService is running and false when the service is off, the code works.
I'm using RoboMongo as a GUI for MongoDB and after the code runs i still don't see the Database on the GUI. i need some help what i'm doing wrong
Thanks
The database will not show up in the list until you have added some data. I have not used RoboMongo, but if you create a database in code, and then using the Mongo console to list the databases, you will not see anything. Add some data and try again, the database will show up in the list of the 'show dbs' command.
I'm trying to query a view using TouchDB in C#. I used the binding between TouchDB and MonoTouch available here : https://github.com/mono/monotouch-bindings/tree/master/Couchbase
When the emit delegate method is called, I get a "System.Runtime.InteropServices.MarshalDirectiveException" saying "The type MonoTouch.Foundation.NSObject which is passed to unmanaged code must have a StructLayout attribute."
I found this bug report here : https://bugzilla.xamarin.com/show_bug.cgi?id=4781 that is similar to my problem but there isn't any updates since July 27, 2012.
Here's my test code :
CouchTouchDBServer server = new CouchTouchDBServer ();
CouchDatabase database = server.GetDatabase ("grocery-sync");
database.TracksChanges = true;
// Create a test view
design = database.DesignDocumentWithName ("grocery");
design.DefineView ("testView", (doc,emit) => {
emit (doc, doc); // Crashes here
}, "1.0");
// Query the view
CouchQuery query = design.CereateQuery("testView");
RestOperation op = query.Start();
string response = op.ResponseBody.AsString;
Console.WriteLine(response);
Has anyone successfully queried a view on TouchDB with MonoTouch? Thanks for your help
It seems to be a bug of Xamarin
I am trying to save data to my database. What I want is that when the button is pressed, data is saved to the database permanently. I've done tests where code is saved while the application is running. The saved data is viewable. But when I terminate the application, the data is not present when I view the data for that table in visual studio. I've provided the code that I am using for testing.
private void btn_otrFun_Click(object sender, EventArgs e)
{
tblCheese cheese = new tblCheese();
string cheesename = "TestCheese";
cheese.CheeseName = cheesename;
cheese.CheeseGroup = 1;
cheeseEntity.tblCheese.AddObject(cheese);
cheeseEntity.SaveChanges();
}
Here is where I am getting the context form. It is instantiated at the beginnning of the form.
private CheeseWorld_DatabaseEntities cheeseEntity = new CheeseWorld_DatabaseEntities(); //instanciate new database entities
And further I am using this snippet to retrieve data from the the database to dynamically created buttons.
var cheeselist = cheeseEntity.ExecuteStoreQuery<tblCheese>("Select * FROM tblCheese WHERE cheeseGroup = 1", null).ToList();
Hope these further details help. If more are required, let me know.
You've departed from the normal pattern we usually use for this... maybe try putting it back to something like this... (I don't see where you are getting the context)
using (var context = new cheeseEntity()) {
tblCheese cheese = new tblCheese();
cheese.CheeseName = "TestCheese";
cheese.CheeseGroup = 1;
context.tblCheese.Add(cheese);
context.SaveChanges();
}
This is covered in the documentation: http://msdn.microsoft.com/en-us/data/jj593489
(Pay attention to the bottom where it shows how to trace the generated SQL)
NOTE: I am using Add instead of AddObject.