根据Service Stack Ormlite文档.我应该在调试模式下生成sql查询.但是,我无法看到这些疑问.简单的代码
private static readonly string DataDirLoc =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
"\\TargetIntegration\\Test\\Debug\\";
private readonly string dbFileName = DataDirLoc +
"Test.db3";
[Test]
public void Can_Generate_log() {
//var writer = new TextWriterTraceListener(System.Console.Out);
//Debug.Listeners.Add(writer);
Debug.Write("this is a try");
var dbFact = new OrmLiteConnectionFactory("Data Source={0};Version=3;".FormatParams(dbFileName), true,
SqliteOrmLiteDialectProvider.Instance);
IDbConnection dbConnection = dbFact.OpenDbConnection();
var dbCommand = dbConnection.CreateCommand();
dbCommand.CreateTable<Contact>();
}
Run Code Online (Sandbox Code Playgroud) ServiceStack OrmLite究竟是如何处理默认和计算列的?
具体来说,我收到了错误
The column "PointsAvailable" cannot be modified because it is either a computed column or is the result of a UNION operator.
Run Code Online (Sandbox Code Playgroud)
此列配置为SQL Server 2008数据库中的计算列.
OrmLite似乎对计算列做了一些事情,因为您可以将属性'[ServiceStack.DataAnnotations.Compute]'添加到模型中的属性.
进入代码,调用'OrmLiteDialetBase.cs'中的函数'ToInsertRowStatement'.当该函数检查是否设置了AutoIncrement属性时,它不检查是否设置了IsComputed属性.
我不知道这是一个错误,还是我错了.
我正在使用ServiceStack.ORMLite实现Repository Pattern,如下所示:
public class MyRepository : IMyRepository
{
private IDbConnectionFactory DbConnectionFactory = null;
public MyRepository(IDbConnectionFactory dbConnectionFactory)
{
DbConnectionFactory = dbConnectionFactory;
}
public void MyMethod()
{
using (var connection = DbConnectionFactory.OpenDbConnection())
using (var cmd = connection.CreateCommand())
{
//Do something here
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我需要在DbTransaction中扭曲一些数据库操作时,我不知道如何处理DbTransaction.它看起来像是TransactionScope一个解决方案,但我不知道这是否太重了.
我怎样才能在ServiceStack.OrmLite代码中首先使用nText数据类型?
public class Email
{
[AutoIncrement]
public long ID { get; set; }
public DateTime Date { get; set; }
public string From { get; set; }
public string Subject { get; set; }
nText =>
public string Body { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如果我使用字符串数据类型,ormlite在数据库中生成nVarchar(8000)
我需要超过8000个字符的数据
OrmLite能否识别我的POCO和我的架构之间的差异,并根据需要自动添加(或删除)列以强制架构与我的POCO保持同步?
如果此功能不存在,我是否有办法查询数据库的表模式,以便我可以手动执行同步?我找到了这个,但是我使用的是安装了ServiceStack的OrmLite版本,但就我而言,我找不到具有TableInfo类的命名空间.
我为我的项目选择了ServiceStack OrmLite,这是一个纯粹的面向数据的应用程序.我愿意允许最终用户创建自己的XML格式定义的对象类型,这些格式将用于在运行时使用CodeDOM生成类.
我还将定义应用程序所需的一些"系统"对象(即User)但我无法预见最终用户将使用的所有属性,因此我正在寻找一种方法来允许扩展我在设计时创建的类.样品波纹管
public class User
{
public Guid Uid { get; set; }
public String Username { get; set; }
public String Password { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
最终用户希望拥有Email和Address.他应该能够将2个属性添加到上层类,并且整个类将是(OrmLite仍然可以使用它,因为它允许覆盖:
public class User
{
public Guid Uid { get; set; }
public String Username { get; set; }
public String Password { get; set; }
public String Email{ get; set; }
public String Address { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我知道可能存在崩溃系统的风险(如果类已经实例化),所以我正在寻找避免这个问题并模仿我需要的最佳方法.
我已经得到了ServiceStack MiniProfiler在我APPHOST(在的Application_Start)启用,我可以查看我的网页通过OrmLite生成的SQL.(使用SS v3.9.59.0)
我不能在轮廓跟踪看到的是绑定参数的值.因此,如果OrmLite将LINQ表达式转换为@ 0,我无法看到作为查询的一部分发送到DB的值.
以下是分析器的示例跟踪:
SELECT "SettingGroup" , "SettingKey" , "LastModified" , "SettingValue"
FROM "GlobalSetting"
WHERE (("SettingGroup" = @0) AND ("SettingKey" = 'a3849d59864b252a2022b4b8a164add1'))
Run Code Online (Sandbox Code Playgroud)
我真的很想知道@0为这个查询发送了什么值.
protected void Application_Start(object sender, EventArgs e)
{
Profiler.Settings.SqlFormatter = new InlineFormatter(true);
new AppHost().Init();
}
Run Code Online (Sandbox Code Playgroud)
我尝试了一些Profiler.Settings.SqlFormatter属性的变种:
SqlFormatter = new InlineFormatter();SqlFormatter = new InlineFormatter(true);SqlFormatter = new SqlServerFormatter();SqlFormatter,将其保留为默认值所有这些都有相同的结果,只显示@0但不显示其价值.
如果单击"共享"链接,我可以在生成的JSON数组中看到绑定参数名称及其值.我只是在渲染的探查器输出中看不到它.
有什么想法,我需要做什么来显示参数值?
在Web项目发布期间,我遇到了一个引用库(ServiceStack.OrmLite)部署的奇怪问题.这是工作正常,直到最后一周左右,而现在突然有些ServiceStack的DLL不被当项目发布到本地文件系统,FTP或Web部署,从Visual Studio或MSBuild的复制.
OrmLite引用通过nuget添加到类lib项目中.类lib项目引用被添加到主Web App项目中.当我发布Web App项目时,它编译并复制除五个ServiceStack.OrmLite DLL中的三个(即ServiceStack.Common,ServiceStack.Interfaces和ServiceStack.Text未复制)之外的所有文件.我已经检查(甚至重置)所有DLL引用的'Copy Local'属性为'true',但问题仍然存在.我还检查过OrmLite未在GAC注册.
任何提示或建议表示赞赏.
更新1:
我遇到了一堆与同一问题相关的帖子(但特别是ServiceStack没有).似乎Visual Studio和msbuild [正确地]在发布期间忽略项目中的任何间接引用.
以下是我遇到的一些解决方案:
也参考主项目中的程序集.
使用构建脚本将DLL复制为构建后事件.
向类lib添加一个虚拟(模拟)方法,并从发布期间未复制的程序集或命名空间中实例化任何类.我选择了这个选项,它部分地解决了这个问题.现在,ServiceStack.Common和ServiceStack.Text被复制,但ServiceStack.Interfaces仍然没有被复制,即使我已经创建了一个'ServiceStack.Logging.LogManager'的模拟实例,它是ServiceStack.Interfaces的一部分.所以,基本上我还是卡住了.
嗨,我正在使用Ormlite运行ServiceStack,我遇到了这个错误.以前它工作正常.我不确定我所改变的是什么导致了这个错误.我刚刚使用了一个简单的db.Select()调用,它会抛出此错误.我尝试了各种方法,比如更新nuget包,清理和重建项目等,但它们都不起作用.
System.InvalidProgramException was caught
_HResult=-2146233030
_message=JIT Compiler encountered an internal limitation.
HResult=-2146233030
IsTransient=false
Message=JIT Compiler encountered an internal limitation.
Source=ServiceStack.OrmLite
StackTrace:
at ServiceStack.OrmLite.OrmLiteConfig.get_ExecFilter()
at ServiceStack.OrmLite.ReadConnectionExtensions.Exec[T](IDbConnection dbConn, Func`2 filter)
at ServiceStack.OrmLite.ReadConnectionExtensions.Select[T](IDbConnection dbConn, Expression`1 predicate)
InnerException:
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议可能出错的地方?
我是LINQ和OrmLite/MySql的新手.我有一个服务请求参数,需要导致where子句:
`Name` LIKE '%something%' OR `Name` LIKE '%something%else%'
Run Code Online (Sandbox Code Playgroud)
我知道我可以创建一个IN()或一个=条款,通过:
ev.Where(rn => Sql.In(rn.Name, request.Name)); // Assuming an array here
ev.Where(rn => rn.Name== request.Name));
Run Code Online (Sandbox Code Playgroud)
但我似乎无法找到一个让我建立起来的结构LIKE.另外,Name实际上是一个别名,所以我试图避免手动构造where子句.
servicestack ×9
c# ×5
sql-server ×2
.net ×1
.net-4.5 ×1
code-first ×1
poco ×1
properties ×1
runtime ×1