Webview giving Column Does not Exist Error - vb.net

I am using
MVC 3
VB.NET and
Razor ViewEngine.
I am playing around with WebGrid in my application and it is telling me "failEmList" does not exist.
Below is the code from the calling Function, the View, and the part of the model that it is getting the data from.
FailEmailSends is just a List(of string) and has lines with single entries of email Addresses.
Dim vm As New MassEmailVM
For Each _fail In failEmailSends
vm.failEmList.Add(_fail)
Next
ViewBag.succCount = succCount.ToString
ViewBag.failECount = failEmailCount.ToString
Return View(vm)
View is as follows:
#Modeltype xxxxxxxxxxxxx
#Code
ViewData("Title") = "Mass Emails Sent"
End Code
<table>
<tr><th>Total Sent</th><td>#ViewBag.succCount</td></tr>
<tr><th>Total Fail</th><td>#ViewBag.failECount</td></tr>
<tr><th>Fail Email Addresses</th></tr>
</table>
#code
Dim grid = New WebGrid(Model.failEmList)
End Code
<div id="grid">
#grid.GetHtml(
tableStyle:="grid",
headerStyle:="head",
alternatingRowStyle:="alt",
columns:=grid.Columns(
grid.Column("failEmList", "Email List")
))
</div>
Relevant part of view Model:
Private _failEmList As New List(Of String)
Public Property failEmList() As List(Of String)
Get
Return _failEmList
End Get
Set(ByVal value As List(Of String))
_failEmList = value
End Set
End Property
Any ideas why this is throwing the following error:
System.InvalidOperationException was unhandled by user code
Message=Column "failEmList" does not exist.
Source=System.Web.Helpers
StackTrace:
at System.Web.Helpers.WebGridRow.get_Item(String name)
at System.Web.Helpers.WebGrid.GetTableBodyHtml(IEnumerable`1 columns, String rowStyle, String alternatingRowStyle, String selectedRowStyle)
at System.Web.Helpers.WebGrid.Table(String tableStyle, String headerStyle, String footerStyle, String rowStyle, String alternatingRowStyle, String selectedRowStyle, String caption, Boolean displayHeader, Boolean fillEmptyRows, String emptyRowCellValue, IEnumerable`1 columns, IEnumerable`1 exclusions, Func`2 footer, Object htmlAttributes)
at System.Web.Helpers.WebGrid.GetHtml(String tableStyle, String headerStyle, String footerStyle, String rowStyle, String alternatingRowStyle, String selectedRowStyle, String caption, Boolean displayHeader, Boolean fillEmptyRows, String emptyRowCellValue, IEnumerable`1 columns, IEnumerable`1 exclusions, WebGridPagerModes mode, String firstText, String previousText, String nextText, String lastText, Int32 numericLinksCount, Object htmlAttributes)
at ASP._Page_Views_Admin_MassEmailsSent_vbhtml.Execute() in C:\Users\Skindeep\Documents\Visual Studio 2010\Projects\xxxxxxxxxx\Views\Admin\MassEmailsSent.vbhtml:line 21
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.StartPage.RunPage()
at System.Web.WebPages.StartPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
InnerException:

You may try the following:
#Code
Dim grid = New WebGrid(Model.failEmList)
End Code
<div id="grid">
#grid.GetHtml(
tableStyle:= "grid",
headerStyle:= "head",
alternatingRowStyle:= "alt",
columns:= grid.Columns(
grid.Column(format:= Function(item) item, header:= "Email List")
)
)
</div>

Try this
#grid.GetHtml(
columns: new[] {
grid.Column(format: (item) => item)
}
)

In case it helps someone, in my case I made a copy/paste error, and forgot to change the source when declaring the grid! Once I corrected the first column with the suggestions above, the second column threw the same error.
Dim grid = New WebGrid(Model.WasTheWrongNameHere)

Related

NHibernate create criteria, add Restrictions on related table with nullable foreign key

I work on a Api project in .NET core 2.2 with NHibernate (5.2.5)
Table A has nullable foreign key from table B
I need to create a criteria to filter Table A, using a nullable foreign key (which is not null) that points to Table B, where the Status in Table B is 3
This is something what I have tried:
var criteria = _session.CreateCriteria<AgencyAgreement>();criteria.Add(Restrictions.Eq("BookingCartItem.Status", (int)BookingCartStatus.Cancelled));
also with and operator
criteria.Add(Restrictions.And(Restrictions.IsNotNull("BookingCartItem"), Restrictions.Eq("BookingCartItem.Status", (int)BookingCartStatus.Cancelled)));
but this is what I get as Error
at NHibernate.Persister.Entity.AbstractPropertyMapping.GetColumns(String propertyName)\r\n at NHibernate.Persister.Entity.AbstractPropertyMapping.ToColumns(String alias, String propertyName)\r\n at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumnsUsingProjection(ICriteria subcriteria, String propertyName)\r\n at NHibernate.Criterion.CriterionUtil.GetColumnNamesUsingPropertyName(ICriteriaQuery criteriaQuery, ICriteria criteria, String propertyName, Object value, ICriterion critertion)\r\n at NHibernate.Criterion.SimpleExpression.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)\r\n at NHibernate.Criterion.LogicalExpression.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)\r\n at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition()\r\n at NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, ICriteria criteria, String rootEntityName, IDictionary2 enabledFilters)\r\n at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary2 enabledFilters)\r\n at NHibernate.Impl.SessionImpl.ListAsync(CriteriaImpl criteria, IList results, CancellationToken cancellationToken)\r\n at NHibernate.Impl.CriteriaImpl.ListAsync(IList results, CancellationToken cancellationToken)\r\n at NHibernate.Impl.CriteriaImpl.ListAsync[T](CancellationToken cancellationToken)\r\n at HASELT.merakzy.Services.Features.Documents.QueryTravelAgreements.Handler.Handle(Request request, CancellationToken cancellationToken) in C:\Users\Asus\Desktop\merakzy-sourcecode\merakzy-master\src\HASELT.merakzy.Services\Features\AgencyDocuments\QueryTravelAgreements.cs:line 115\r\n at MediatR.Pipeline.RequestPostProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)\r\n at MediatR.Pipeline.RequestPreProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)\r\n at lambda_method(Closure , Object )\r\n at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()\r\n at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at System.Threading.Tasks.ValueTask`1.get_Result()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
var criteria = _session.CreateCriteria<AgencyAgreement>();
criteria.CreateCriteria(nameof(AgencyAgreement.BookingCartItem))
.Add(Restrictions.Eq("Status", (int)BookingCartStatus.Cancelled));
or using linq if the properties are known at compile time
var query = _session.Query<AgencyAgreement>();
query = query.Where(a => a.BookingCartItem.Status == (int)BookingCartStatus.Cancelled);

Failed insert or update when add type column long text using NHibernate in VB.NET

I'm using Nhibernate 4 and FluentNhibernate 2.0.3 with db Microsoft Access 2000. I can't save the entry on the DB because i'm getting an error when I go to insert the Note field sending a request HTTP POST for example:
{
"Note": "bla bla bla"
}
NOTE: In the database table, the column "Note" is setted as "LONG TEXT" (Not Required)
Could It be a problem of conversion of data Types?
Here's the stack trace:
NHibernate.Exceptions.GenericADOException: could not insert: [Domain.Destinatari#1773][SQL: INSERT INTO `Destinatari` (Note, IDDestinatario) VALUES (?, ?)] ---> System.Data.OleDb.OleDbException: Errore di sintassi nell'istruzione INSERT INTO.
in System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
in System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
in System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
in System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
in System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
in System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
in NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
in NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
in NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
in NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
--- Fine della traccia dello stack dell'eccezione interna ---
in NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
in NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
in NHibernate.Action.EntityInsertAction.Execute()
in NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
in NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
in NHibernate.Engine.ActionQueue.ExecuteActions()
in NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
Below my mapping code:
Public Class DestinatariMap
Inherits ClassMap(Of Destinatari)
Public Sub New()
MyBase.New
LazyLoad()
Id(Function(x) x.IDDestinatario).GeneratedBy().Increment()
Map(Function(x) x.Note)
End Sub
End Class
Here's my Domain code:
Public Class Destinatari
Private _ID_Destinatario As Integer
Private _Note As String
Public Overridable Property IDDestinatario() As Integer
Get
Return Me._ID_Destinatario
End Get
Set
Me._ID_Destinatario = Value
End Set
End Property
Public Overridable Property Note() As String
Get
Return Me._Note
End Get
Set
Me._Note = Value
End Set
End Property
End Class
Thanks

How to log multiple fields in EventSource

I am using EventSource to log event. I need to record 30 fields for one event. It works if I pass all 30 fields as string one by one as shown below. I was able to log those events. But when I trying to pass a string[] into the WriteEvent(). The isEnabled() returns false. Is there a better way to pass multiple fields into the WriteEvent() method?
The following is my source code for my event provider.
sealed class NemoTraceLoggingProvider : EventSource
{
public static NemoTraceLoggingProvider Log = new NemoTraceLoggingProvider();
[Event(1, Version = 12)]
public void SendTraceLoggingEvent(string Host, string Machine, string NemoVersion, string TraceId, string Operation, string HttpResult, string CallDuration, string Segment, string InputCells,
string InputTargetCells, string InputTargetContext, string IdentifyEntitySurfaceFormsIterations, string IdentifyEntitySurfaceFormsMaxDuration,
string IdentifyEntitySurfaceFormsInstancesCount, string ResolveMethod2Iterations, string ResolveMethod2MaxDuration,
string ResolveMethod2InstancesCount, string ResolveMethod3Iterations, string ResolveMethod3MaxDuration, string ResolveMethod3InstancesCount,
string ExtractPatternIterations, string ExtractPatternMaxDuration, string ExtractPatternInstancesCount, string NormalizeTextIterations,
string NormalizeTextMaxDuration, string NormalizeTextInstancesCount, string MaxDocumentTopics, string MaxSurfaceTopics, string MaxSurfaceWords,
string MaxTopicWords)
{
if (IsEnabled())
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("TraceLogging: event is send out");
Console.ResetColor();
WriteEvent(1, Host, Machine, NemoVersion, TraceId, Operation, HttpResult, CallDuration, Segment, InputCells,
InputTargetCells, InputTargetContext, IdentifyEntitySurfaceFormsIterations, IdentifyEntitySurfaceFormsMaxDuration,
IdentifyEntitySurfaceFormsInstancesCount, ResolveMethod2Iterations, ResolveMethod2MaxDuration,
ResolveMethod2InstancesCount, ResolveMethod3Iterations, ResolveMethod3MaxDuration, ResolveMethod3InstancesCount,
ExtractPatternIterations, ExtractPatternMaxDuration, ExtractPatternInstancesCount, NormalizeTextIterations,
NormalizeTextMaxDuration, NormalizeTextInstancesCount, MaxDocumentTopics, MaxSurfaceTopics, MaxSurfaceWords,
MaxTopicWords);
}
else
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Not Enabled!!!");
Console.ResetColor();
}
}
}
}
Thanks!

PlatformNotSupportedException CE7

I have a empty project (compact framework 3.5) for pda. I add a imagelist and i add a image in the list. When i deploy the project at a CE7 device (Motorola MC32N0) i get a PlatformNotSupportedException at the line
this.imageList1.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
The stacktrace is:
at System.Globalization.CompareInfo..ctor(Int32 culture)
at System.Globalization.CompareInfo.GetCompareInfo(Int32 culture)
at System.Globalization.CultureInfo.get_CompareInfo()
at System.Collections.Comparer..ctor(CultureInfo culture)
at System.Collections.Comparer..cctor()
at System.OrdinalComparer.EqualsStringImpl(String x, String y)
at System.StringComparerImpl.Equals(Object x, Object y)
at System.Collections.Hashtable.KeyEquals(Object item, Object key)
at System.Collections.Hashtable.get_Item(Object key)
at System.Globalization.CultureInfo.GetCultureInfoHelper(Int32 lcid, String name, String altName)
at System.Globalization.CultureInfo.GetCultureInfo(String name)
at System.Globalization.CompareInfo.GetSortingLCID(Int32 culture)
at System.Globalization.CompareInfo..ctor(Int32 culture)
at System.Globalization.CompareInfo.GetCompareInfo(Int32 culture)
at System.Globalization.CultureInfo.get_CompareInfo()
at System.Globalization.CultureInfo.GetHashCode()
at System.Collections.Hashtable.GetHash(Object key)
at System.Collections.Hashtable.InitHash(Object key, Int32 hashsize, UInt32& seed, UInt32& incr)
at System.Collections.Hashtable.get_Item(Object key)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture)
at System.Resources.ResourceManager.GetObject(String name)
at SmartDeviceProject5.Form1.InitializeComponent()
at SmartDeviceProject5.Form1..ctor()
at SmartDeviceProject5.Program.Main()
I only get this exception in CE7. Any ideas?
I think MC32xx has only a "core" CE7. I had a similar problem. Have you got installed Compact Framework 3.5 properly. What does the windows\wceload.exe show you? Maybe you have to install this seperately.

Value does not fall within the expected range VB.NET 2012 Clickonce

I m getting crazy... A solution with 8 projects, and suddenly when publishing using ClickOnce and trying to run the app on the client machine appears this error :
*ERROR DETAILS
Following errors were detected during this operation.
* [16/04/2014 7:23:12] System.ArgumentException
- Value does not fall within the expected range.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.NativeMethods.CorLaunchApplication(UInt32 hostType, String applicationFullName, Int32 manifestPathsCount, String[] manifestPaths, Int32 activationDataCount, String[] activationData, PROCESS_INFORMATION processInformation)
at System.Deployment.Application.ComponentStore.ActivateApplication(DefinitionAppId appId, String activationParameter, Boolean useActivationParameter)
at System.Deployment.Application.SubscriptionStore.ActivateApplication(DefinitionAppId appId, String activationParameter, Boolean useActivationParameter)
at System.Deployment.Application.ApplicationActivator.Activate(DefinitionAppId appId, AssemblyManifest appManifest, String activationParameter, Boolean useActivationParameter)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)*
anybody can help me ???? Thanks in advance to all who read this question.