lifeng-liang / dbentry Goto Github PK
View Code? Open in Web Editor NEWDbEntry.Net (Leafing Framework) is a lightweight, high performance ORM compnent for .Net.
DbEntry.Net (Leafing Framework) is a lightweight, high performance ORM compnent for .Net.
我在使用mdb数据库,可以使用相对路径吗?或者在软件中利用字符串来配置连接。
Dear Sir,
I am using Non Dot Net dll file in .net Application.
Due to this, it gives typeinitialisation error.
after digging into problem, found that problem occurs due to SearchAssemblies method in SimpleContainer.cs.
i changed the code a little bit and it started functioning.
'try
{
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
}
catch (Exception) { }'
let me know, if this is the correct way?
or any other solution on the same.
regards
Shailesh
I have config AutoCreateTable/FixScheme,after 'createtable' method executed in 'DbEntry.UsingTransaction',it will throw error.
“System.NotImplementedException”类型的异常在 Leafing.Data.dll 中发生,但未在用户代码中进行处理
其他信息: 未实现该方法或操作。
如题,在两处打断点后没被命中断点,似乎2个事件没有被触发
因为历史原因,有表主键不是id的情况, 定义为 IDbObject
。设置了某字段为LazyLoad
给该字段赋值时 字段名.value=xxx
,会报 未将对象设置引用到对象实例 的错误。调试 该字段当时为null
请问要怎么更新懒加载字段呢? 谢谢。
//user.cs
public class User : DbObjectModel<User >
{
[OrderBy("Id")]
public HasMany<Book> Books { get; private set; }
}
//book.cs
public class Book: DbObjectModel<Book>
{
public BelongsTo<User, long> UserId { get; set; }
[Exclude]
public User User
{
get { return UserId .Value; }
set { UserId Value = value; }
}
}
我尝试
Leafing.Data.DbEntry.From<Book>().Where(c => c.UserId == 1).Delete();
//or
Leafing.Data.DbEntry.DeleteBy<Book>(c => c.UserId == 1);
//or
Book.DeleteBy(c => c.UserId == 1);
均报错。
运算符“==”无法应用于“BelongsTo<User, long>”和“int”类型的操作
手册中,相关的测试用例中 关于这部分 也都看了。 没找到 相似的代码。 还请解答下。 谢谢。
对于GIT上最新版本, 应用于System.Data.SQLite.dll不能正常运行。
配置文件如下:
<Leafing.Settings>
<add key="AutoCreateTable" value="true"/>
<add key="AutoScheme" value="CreateTable" />
<add key="DataBase" value="@SQLite : @~Test.db;" />
<add key="DbProviderFactory" value="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</Leafing.Settings>
此配置不能通过测试, 对于4.2版本,能正常运行,请修复。
看源码 Leafing.Data\Model\Saver\SimpleObjectSaver.cs (47)
发现 OnUpdating 是在 Composer.GetUpdateStatement(obj, iwc) 之后,
但是我的理解 OnInserting OnUpdating 更准确的描述为 OnBeforeInserte OnBeforeUpdate,
比如以下需求
protected override void OnInserting(){
LastEditTime = DateTime.Now;
base.OnInserting();
}
protected override void OnUpdating() {
LastEditTime = DateTime.Now;
base.OnUpdating();
}
结果导致 OnUpdating 中的赋值失效, OnUpdating 变成 OnUpdated 了
OnInserting 没有此问题.
修改源码 Leafing.Data\Model\Saver\DbModelSaver.cs(26) 添加
o.RaiseUpdating();
就没有此问题
重现条件如下:
1、传进去的SQL语句中包含字符串
2、该字符串中同时包含换行与英文问号
举例:
insert into table1(field1) values('sometext?
Sometex')
经查,问题原因在于GetSqlStatement中使用的正则表达式"'.*'|\?"是默认的多行模式,导致字符串中含有换行时可以匹配到问号,从而进入参数配对环节,最终对参数数组的访问就会越界
ObjectDeletedText、ObjectUpdatedText 等属性中的变量{0} 的值无法进行配置,默认模型的类名
`using Leafing.Data;
using Leafing.Data.Definition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace myTest
{
class Program
{
static void Main(string[] args)
{
init1();
init2();
Console.ReadLine();
}
static void init1()
{
DbEntry.DropAndCreate(typeof(Temp_SystemDept));
var z = new Temp_SystemDept { DeptName = "总公司" };
z.ParentDept.Value = null;
z.Save();
Console.WriteLine(Temp_SystemDept.FindById(1).ToString());
var z1 = new Temp_SystemDept { DeptName = "长沙分公司" };
z1.ParentDept.Value = z;
z1.Save();
Console.WriteLine(Temp_SystemDept.FindById(1).ToString());
var z2 = new Temp_SystemDept { DeptName = "上海分公司" };
z2.ParentDept.Value = z;
z2.Save();
Console.WriteLine(Temp_SystemDept.FindById(1).ToString());
Console.WriteLine("done");
}
static void init2()
{
DbEntry.DropAndCreate(typeof(Temp_SystemDeptTree));
var z = new Temp_SystemDeptTree { DeptName = "总公司", Parent = null };
z.Save();
Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());
new Temp_SystemDeptTree { DeptName = "长沙分公司", Parent = z }.Save();
Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());
new Temp_SystemDeptTree { DeptName = "上海分公司", Parent = z }.Save();
Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());
Console.WriteLine("done");
}
}
public class Temp_SystemDept : DbObjectModel<Temp_SystemDept, int>
{
[Length(30)]
public string DeptName { get; set; }
[DbColumn("ParentDeptId")]
public BelongsTo<Temp_SystemDept, int> ParentDept { get; set; }
public HasMany<Temp_SystemDept> ChildDepts { get; set; }
}
public class Temp_SystemDeptTree : DbObjectModelAsTree<Temp_SystemDeptTree, int>
{
[Length(30)]
public string DeptName { get; set; }
}
}
`
Console结果
{ Id = 1, DeptName = 总公司, ParentDeptId = }
{ Id = 1, DeptName = 总公司, ParentDeptId = }
{ Id = 1, DeptName = 总公司, ParentDeptId = 2 } ———————被更新了
done
{ Id = 1, DeptName = 总公司, BelongsTo_Id = }
{ Id = 1, DeptName = 总公司, BelongsTo_Id = }
{ Id = 1, DeptName = 总公司, BelongsTo_Id = 2 } ——————被更新了
done
1、提交表单DataSource校验未通过时,表单中控件的class样式表被替换成为ErrInput,原有样式丢失
2、DataSource 提交成功(修改、删除、更新)给出提示后,将表单中控件的原有样式清空,应保留原有样式
仔细看了下面的测试用例。
但是我自己的代码实际用行时,就会更新所有字段。
using Leafing.Data.Definition;
namespace test
public class Case : IDbObject
{
[DbKey, DbColumn("case_id")]
public int Id { get; set; }
public int Year { get; set; }
public string Number { get; set; }
public string Content { get; set; }
//... 其他字段
public string OtherContent { get; set; }
}
var p = new Case
{
Year = year,
Number = number,
Id = id
};
DbEntry.Update(p);
/*执行时,打印的 sql 语句 会将 Case 的所有字段全部进行更新,造成其他字段属性都丢了。
请问应该如何只更新部分字段呢?*/
谢谢大家,请多多指导。
N1QL语法还是挺方便的.
而且还有官方的linq操作的开源类.
https://github.com/couchbaselabs/Linq2Couchbase
可以参考
HasAndBelongsToMany
进行关联,生成的关联表字段会以第一个获取到的字段类型生成关联。mTask
ID 类型为 GUID, mUser
ID类型为 long,则生成的R_mTask_mUser
里的 mTask_Id
和 mUser_Id
均为GUID
类型。mUser
public class mUser : DbObjectModel<mUser>
{
/// <summary>
/// 参与过的任务
/// </summary>
[HasAndBelongsToMany]
public IList<mTask> join_tasks { get; private set; }
//....
//some code
//....
}
mTask
public class mTask : DbObjectModel<mTask, Guid>
{
/// <summary>
/// 参与成员
/// </summary>
[HasAndBelongsToMany]
public IList<mUser> members { get; private set; }
//....
//some code
//....
}
Logger is created before SimpleContainer create.
FIX:
SimpleContainer.cs
remove using Leafing.Core.Logging;
replace:
try {
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
} catch (Exception ex) {
Logger.System.Warn(ex);
}
with:
try {
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
} catch (Exception ex) {
throw ex;
}
原有正常页面用最新源码后,提交表单时出现 control xxx not find!
HI ALL:
使用ActAsTree功能时, 存在HasMany的情况下,数据库表UxFile的BelongTo_ID不完全正确。子对象正常,父对象此值给出了一个错误值。 请修复此情况。
` [DbContext("JbCtx")]
public class UxFile : DbObjectModelAsTree
{
public string Name { get; set; }
public HasMany<MyJobStep> MyJobStep { get;private set; }
}
[DbContext("JbCtx")]
public class MyJobStep : DbObjectModel<MyJobStep>
{
public int IdAny { get; set; }
public BelongsTo<UxFile> _uxFile { get; set; }
[Exclude]
public UxFile UxFile
{
get { return _uxFile.Value; }
set { _uxFile.Value = value; }
}
}
class TestHelper
{
private static void DoTest()
{
var f2 = new UxFile()
{
Name = "F2"
};
var f3 = new UxFile()
{
Name = "F3"
};
var fi = new UxFile()
{
Name = "F1"
};
fi.Children.Add(f2);
fi.Children.Add(f3);
var mm = new MyJobStep();
mm.UxFile = fi;
mm.Save();
}
}
`
设置了DataSource的CssWarning后(由多个css组合),NoticeMessageID 指定的label控件的css也被完全替换成由多个css组合的CssWarning,导致label样式混乱
或可考虑在任何情况下表单里的空间都显示CssCommon设定的css,要提示信息时在 CssCommon 属性基础上增加获清除 Warning
Log Sql to DatabaseLog may cause transaction error.
DataSource 的 NoticeMessageID 设置为 Label 后,表单验证不通过时报错。
将
NoticeLabelAdapter.cs 中的 private List _msgList 改成 private List _msgList = new List(); 既可
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.